org.n52.svalbard.write.Soap12XmlStreamWriter Maven / Gradle / Ivy
The newest version!
/*
* Copyright (C) 2015-2022 52°North Spatial Information Research GmbH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.n52.svalbard.write;
import java.io.OutputStream;
import java.util.Set;
import javax.xml.stream.XMLStreamException;
import org.apache.xmlbeans.XmlObject;
import org.n52.janmayen.http.MediaTypes;
import org.n52.shetland.ogc.ows.exception.OwsExceptionReport;
import org.n52.shetland.ogc.ows.service.OwsOperationKey;
import org.n52.shetland.ogc.ows.service.OwsServiceResponse;
import org.n52.shetland.w3c.SchemaLocation;
import org.n52.shetland.w3c.W3CConstants;
import org.n52.shetland.w3c.soap.SoapConstants;
import org.n52.shetland.w3c.soap.SoapFault;
import org.n52.shetland.w3c.soap.SoapResponse;
import org.n52.svalbard.encode.Encoder;
import org.n52.svalbard.encode.EncodingContext;
import org.n52.svalbard.encode.OperationResponseEncoderKey;
import org.n52.svalbard.encode.SchemaAwareEncoder;
import org.n52.svalbard.encode.StreamingEncoder;
import org.n52.svalbard.encode.StreamingEncoderFlags;
import org.n52.svalbard.encode.XmlBeansEncodingFlags;
import org.n52.svalbard.encode.exception.EncodingException;
import org.n52.svalbard.encode.exception.NoEncoderForKeyException;
import com.google.common.collect.Sets;
/**
* {@link XmlStreamWriter} implementation for SOAP 1.2
*
* @author Carsten Hollmann
* @since 1.0.0
*
*/
public class Soap12XmlStreamWriter extends XmlStreamWriter {
public Soap12XmlStreamWriter(EncodingContext context, OutputStream outputStream, SoapResponse element)
throws XMLStreamException {
super(context, outputStream, element);
}
@Override
public void write() throws EncodingException, XMLStreamException {
start();
writeSoapEnvelope();
end();
finish();
}
/**
* Write the SOAP 1.2. envelope element
*
* @throws XMLStreamException If an error occurs when writing to {@link OutputStream} If an error occurs when
* writing to {@link OutputStream}
* @throws EncodingException If an encoding error occurs
*/
protected void writeSoapEnvelope() throws XMLStreamException, EncodingException {
start(SoapConstants.SOAP_12_ENVELOPE);
namespace(W3CConstants.NS_XLINK_PREFIX, W3CConstants.NS_XLINK);
namespace(SoapConstants.NS_SOAP_PREFIX, SoapConstants.NS_SOAP_12);
schemaLocation(getSchemaLocation());
// writeSoapHeader()
writeSoapBody();
end(SoapConstants.SOAP_12_ENVELOPE);
}
protected Set getSchemaLocation()
throws EncodingException, XMLStreamException {
SoapResponse response = getElement();
Set schemaLocations = Sets.newHashSet();
schemaLocations.add(SoapConstants.SOAP_12_SCHEMA_LOCATION);
if (response.isSetBodyContent()) {
Encoder
© 2015 - 2024 Weber Informatics LLC | Privacy Policy