Search in sources :

Example 1 with SoapChain

use of org.n52.shetland.w3c.soap.SoapChain in project arctic-sea by 52North.

the class SoapBinding method doPostOperation.

@Override
public void doPostOperation(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws HTTPException, IOException {
    final SoapChain chain = new SoapChain(httpRequest, httpResponse);
    try {
        parseSoapRequest(chain);
        checkForContext(chain, getRequestContext(httpRequest));
        createSoapResponse(chain);
        if (!chain.getSoapRequest().hasSoapFault()) {
            // parseBodyRequest(chain);
            createBodyResponse(chain);
        }
        writeResponse(chain);
    } catch (OwsExceptionReport t) {
        writeOwsExceptionReport(chain, t);
    }
}
Also used : SoapChain(org.n52.shetland.w3c.soap.SoapChain) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Example 2 with SoapChain

use of org.n52.shetland.w3c.soap.SoapChain in project arctic-sea by 52North.

the class SoapBinding method encodeSoapResponse.

private Object encodeSoapResponse(SoapChain chain) throws OwsExceptionReport, NoEncoderForKeyException {
    EncoderKey key = new XmlEncoderKey(chain.getSoapResponse().getSoapNamespace(), chain.getSoapResponse().getClass());
    Encoder<?, SoapResponse> encoder = getEncoder(key);
    if (encoder != null) {
        try {
            return encoder.encode(chain.getSoapResponse());
        } catch (OwsEncodingException ex) {
            throw ex.getCause();
        } catch (EncodingException ex) {
            throw new NoApplicableCodeException().withMessage(ex.getMessage()).causedBy(ex);
        }
    } else {
        NoEncoderForKeyException cause = new NoEncoderForKeyException(key);
        throw new NoApplicableCodeException().withMessage(cause.getMessage()).causedBy(cause);
    }
}
Also used : NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) SoapResponse(org.n52.shetland.w3c.soap.SoapResponse) EncodingException(org.n52.svalbard.encode.exception.EncodingException) OwsEncodingException(org.n52.iceland.coding.encode.OwsEncodingException) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) EncoderKey(org.n52.svalbard.encode.EncoderKey) XmlEncoderKey(org.n52.svalbard.encode.XmlEncoderKey) XmlEncoderKey(org.n52.svalbard.encode.XmlEncoderKey) OwsEncodingException(org.n52.iceland.coding.encode.OwsEncodingException)

Example 3 with SoapChain

use of org.n52.shetland.w3c.soap.SoapChain in project arctic-sea by 52North.

the class SoapBinding method createBodyResponse.

private void createBodyResponse(SoapChain chain) throws OwsExceptionReport {
    OwsServiceRequest req = chain.getSoapRequest().getSoapBodyContent();
    chain.setBodyResponse(getServiceOperator(req).receiveRequest(req));
}
Also used : OwsServiceRequest(org.n52.shetland.ogc.ows.service.OwsServiceRequest)

Example 4 with SoapChain

use of org.n52.shetland.w3c.soap.SoapChain in project arctic-sea by 52North.

the class SoapBinding method writeOwsExceptionReport.

private void writeOwsExceptionReport(SoapChain chain, OwsExceptionReport owse) throws HTTPException, IOException {
    try {
        String version = chain.hasBodyRequest() ? chain.getBodyRequest().getVersion() : null;
        getEventBus().submit(new ExceptionEvent(owse));
        chain.getSoapResponse().setException(owse.setVersion(version));
        if (!chain.getSoapResponse().hasSoapVersion()) {
            chain.getSoapResponse().setSoapVersion(SOAPConstants.SOAP_1_2_PROTOCOL);
        }
        if (!chain.getSoapResponse().hasSoapNamespace()) {
            chain.getSoapResponse().setSoapNamespace(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE);
        }
        if (chain.getSoapResponse().hasException() && chain.getSoapResponse().getException().hasStatus()) {
            chain.getHttpResponse().setStatus(chain.getSoapResponse().getException().getStatus().getCode());
        }
        checkSoapInjection(chain);
        httpUtils.writeObject(chain.getHttpRequest(), chain.getHttpResponse(), checkMediaType(chain), encodeSoapResponse(chain), this);
    } catch (OwsExceptionReport | NoEncoderForKeyException t) {
        throw new HTTPException(HTTPStatus.INTERNAL_SERVER_ERROR, t);
    }
}
Also used : ExceptionEvent(org.n52.iceland.event.events.ExceptionEvent) NoEncoderForKeyException(org.n52.svalbard.encode.exception.NoEncoderForKeyException) HTTPException(org.n52.iceland.exception.HTTPException) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Example 5 with SoapChain

use of org.n52.shetland.w3c.soap.SoapChain in project arctic-sea by 52North.

the class SoapBinding method writeResponse.

private void writeResponse(SoapChain chain) throws IOException, HTTPException {
    MediaType contentType = chooseResponseContentType(chain.getBodyResponse(), HTTPHeaders.getAcceptHeader(chain.getHttpRequest()), getDefaultContentType());
    // TODO allow other bindings to encode response as soap messages
    if (contentType.isCompatible(getDefaultContentType())) {
        checkSoapInjection(chain);
        httpUtils.writeObject(chain.getHttpRequest(), chain.getHttpResponse(), checkMediaType(chain), chain, this);
    } else {
        httpUtils.writeObject(chain.getHttpRequest(), chain.getHttpResponse(), contentType, chain.getBodyResponse(), this);
    }
}
Also used : MediaType(org.n52.janmayen.http.MediaType)

Aggregations

SoapResponse (org.n52.shetland.w3c.soap.SoapResponse)3 NoEncoderForKeyException (org.n52.svalbard.encode.exception.NoEncoderForKeyException)3 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)2 EncoderKey (org.n52.svalbard.encode.EncoderKey)2 OwsEncodingException (org.n52.iceland.coding.encode.OwsEncodingException)1 ExceptionEvent (org.n52.iceland.event.events.ExceptionEvent)1 HTTPException (org.n52.iceland.exception.HTTPException)1 CommunicationObjectWithSoapHeader (org.n52.iceland.service.CommunicationObjectWithSoapHeader)1 MediaType (org.n52.janmayen.http.MediaType)1 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)1 OwsServiceRequest (org.n52.shetland.ogc.ows.service.OwsServiceRequest)1 SoapChain (org.n52.shetland.w3c.soap.SoapChain)1 SoapHeader (org.n52.shetland.w3c.soap.SoapHeader)1 SoapRequest (org.n52.shetland.w3c.soap.SoapRequest)1 XmlEncoderKey (org.n52.svalbard.encode.XmlEncoderKey)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1