Search in sources :

Example 6 with OwsOperationKey

use of org.n52.shetland.ogc.ows.service.OwsOperationKey in project arctic-sea by 52North.

the class AbstractSoapEncoder method getBodyContent.

/**
 * Get the content for the SOAPBody as {@link XmlObject}
 *
 * @param response SOAP response
 *
 * @return SOAPBody content as {@link XmlObject}
 *
 * @throws EncodingException If no encoder is available, the object to encode is not supported or an error occurs
 *                           during the encoding
 */
protected XmlObject getBodyContent(SoapResponse response) throws EncodingException {
    OperationResponseEncoderKey key = new OperationResponseEncoderKey(new OwsOperationKey(response.getBodyContent()), MediaTypes.APPLICATION_XML);
    Encoder<Object, OwsServiceResponse> encoder = getEncoder(key);
    if (encoder == null) {
        throw new NoEncoderForKeyException(key);
    }
    return (XmlObject) encoder.encode(response.getBodyContent());
}
Also used : NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) XmlObject(org.apache.xmlbeans.XmlObject) XmlObject(org.apache.xmlbeans.XmlObject) OwsOperationKey(org.n52.shetland.ogc.ows.service.OwsOperationKey) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse)

Example 7 with OwsOperationKey

use of org.n52.shetland.ogc.ows.service.OwsOperationKey in project arctic-sea by 52North.

the class Soap12XmlStreamWriter method writeBodyContent.

/**
 * Encode and write the {@link OwsServiceResponse} to stream
 *
 * @param bodyResponse The service internal response to encode and write
 *
 * @throws XMLStreamException If an error occurs when writing to {@link OutputStream}
 * @throws EncodingException  If an encoding error occurs
 */
@SuppressWarnings({ "rawtypes", "unchecked" })
protected void writeBodyContent(OwsServiceResponse bodyResponse) throws XMLStreamException, EncodingException {
    Encoder<Object, OwsServiceResponse> encoder = getEncoder(new OperationResponseEncoderKey(new OwsOperationKey(bodyResponse), MediaTypes.APPLICATION_XML));
    if (encoder instanceof StreamingEncoder<?, ?>) {
        EncodingContext ctx = getContext().with(XmlBeansEncodingFlags.DOCUMENT).without(XmlBeansEncodingFlags.PROPERTY_TYPE).without(XmlBeansEncodingFlags.TYPE).with(StreamingEncoderFlags.EMBEDDED, true);
        ((StreamingEncoder) encoder).encode(bodyResponse, getOutputStream(), ctx);
    } else {
        String soapBodyContent = ((XmlObject) encoder.encode(bodyResponse)).xmlText(getXmlOptions());
        rawText(stripXmlDeclaration(soapBodyContent));
    }
}
Also used : EncodingContext(org.n52.svalbard.encode.EncodingContext) OperationResponseEncoderKey(org.n52.svalbard.encode.OperationResponseEncoderKey) XmlObject(org.apache.xmlbeans.XmlObject) XmlObject(org.apache.xmlbeans.XmlObject) StreamingEncoder(org.n52.svalbard.encode.StreamingEncoder) OwsServiceResponse(org.n52.shetland.ogc.ows.service.OwsServiceResponse) OwsOperationKey(org.n52.shetland.ogc.ows.service.OwsOperationKey)

Aggregations

OwsOperationKey (org.n52.shetland.ogc.ows.service.OwsOperationKey)7 XmlObject (org.apache.xmlbeans.XmlObject)3 OwsServiceResponse (org.n52.shetland.ogc.ows.service.OwsServiceResponse)3 OperationResponseEncoderKey (org.n52.svalbard.encode.OperationResponseEncoderKey)2 NoEncoderForKeyException (org.n52.svalbard.encode.exception.NoEncoderForKeyException)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 URI (java.net.URI)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 Set (java.util.Set)1 Predicate (java.util.function.Predicate)1 Collectors.toSet (java.util.stream.Collectors.toSet)1 Stream (java.util.stream.Stream)1