Search in sources :

Example 11 with NoApplicableCodeException

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

the class SoapBinding method createSoapResponse.

// private void parseBodyRequest(SoapChain chain) throws OwsExceptionReport,
// OwsExceptionReport {
// 
// final XmlObject xmlObject = chain.getSoapRequest().getSoapBodyContent();
// DecoderKey key = CodingHelper.getDecoderKey(xmlObject);
// final Decoder<?, XmlObject> bodyDecoder = getDecoder(key);
// if (bodyDecoder == null) {
// throw new NoDecoderForKeyException(key).setStatus(BAD_REQUEST);
// }
// final Object aBodyRequest = bodyDecoder.decode(xmlObject);
// if (!(aBodyRequest instanceof AbstractServiceRequest)) {
// throw new NoApplicableCodeException().withMessage(
// "The returned object is not an AbstractServiceRequest implementation").setStatus(BAD_REQUEST);
// }
// AbstractServiceRequest bodyRequest = (AbstractServiceRequest)
// aBodyRequest;
// bodyRequest.setRequestContext(getRequestContext(chain.getHttpRequest()));
// if (bodyRequest instanceof CommunicationObjectWithSoapHeader) {
// ((CommunicationObjectWithSoapHeader)
// bodyRequest).setSoapHeader(chain.getSoapRequest().getSoapHeader());
// }
// chain.setBodyRequest(bodyRequest);
// }
private void createSoapResponse(SoapChain chain) {
    SoapResponse soapResponse = new SoapResponse();
    soapResponse.setSoapVersion(chain.getSoapRequest().getSoapVersion());
    soapResponse.setSoapNamespace(chain.getSoapRequest().getSoapNamespace());
    soapResponse.setHeader(checkSoapHeaders(chain.getSoapRequest().getSoapHeader()));
    chain.setSoapResponse(soapResponse);
}
Also used : SoapResponse(org.n52.shetland.w3c.soap.SoapResponse)

Example 12 with NoApplicableCodeException

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

the class Soap11Decoder method createEnvelope.

/**
 * Parses SOAP 1.1 Envelope to a SOS internal SOAP request.
 *
 * @param doc Request as xml representation
 *
 * @return SOS internal SOAP request
 *
 * @throws DecodingException if an error occurs.
 */
@Override
protected SoapRequest createEnvelope(XmlObject doc) throws DecodingException {
    SoapRequest soapRequest = new SoapRequest(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, SOAPConstants.SOAP_1_1_PROTOCOL);
    String soapAction = "";
    try {
        SOAPMessage soapMessageRequest;
        try {
            soapMessageRequest = SoapHelper.getSoapMessageForProtocol(SOAPConstants.SOAP_1_1_PROTOCOL, doc.newInputStream());
        } catch (IOException | SOAPException ioe) {
            throw new NoApplicableCodeException().causedBy(ioe).withMessage("Error while parsing SOAPMessage from request string!");
        }
        // if SOAPAction is not spec conform, create SOAPFault
        if (soapAction.isEmpty() || !soapAction.startsWith(SOAP_ACTION)) {
            SoapFault fault = new SoapFault();
            fault.setFaultCode(QN_CLIENT);
            fault.setFaultReason("The SOAPAction parameter in the HTTP-Header is missing or not valid!");
            fault.setLocale(Locale.ENGLISH);
            soapRequest.setSoapFault(fault);
            soapRequest.setSoapFault(fault);
        } else {
            // trim SOAPAction value
            soapAction = soapAction.replace("\"", "").replace(" ", "").replace(SOAP_ACTION, "").trim();
        }
        try {
            if (soapMessageRequest.getSOAPHeader() != null) {
                soapRequest.setSoapHeader(getSoapHeader(soapMessageRequest.getSOAPHeader()));
            }
            soapRequest.setAction(checkSoapAction(soapAction, soapRequest.getSoapHeader()));
            soapRequest.setSoapBodyContent(getSOAPBodyContent(soapMessageRequest));
        } catch (SOAPException | DecodingException soape) {
            throw new NoApplicableCodeException().causedBy(soape).withMessage("Error while parsing SOAPMessage!");
        }
    } catch (OwsExceptionReport owse) {
        throw new DecodingException(owse);
    }
    return soapRequest;
}
Also used : SoapFault(org.n52.shetland.w3c.soap.SoapFault) SoapRequest(org.n52.shetland.w3c.soap.SoapRequest) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) SOAPException(javax.xml.soap.SOAPException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) IOException(java.io.IOException) SOAPMessage(javax.xml.soap.SOAPMessage) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Example 13 with NoApplicableCodeException

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

the class Soap12Decoder method createEnvelope.

/**
 * Parses SOAP 1.2 Envelope to a SOS internal SOAP request.
 *
 * @param doc
 *            request as xml representation
 *
 * @return SOS internal SOAP request
 *
 * @throws DecodingException
 *             if an error occurs.
 */
@Override
protected SoapRequest createEnvelope(XmlObject doc) throws DecodingException {
    SoapRequest soapRequest = new SoapRequest(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, SOAPConstants.SOAP_1_2_PROTOCOL);
    String soapAction = "";
    try {
        SOAPMessage message;
        try {
            message = SoapHelper.getSoapMessageForProtocol(SOAPConstants.SOAP_1_2_PROTOCOL, doc.newInputStream());
        } catch (IOException | SOAPException ioe) {
            throw new NoApplicableCodeException().causedBy(ioe).withMessage("Error while parsing SOAPMessage from request string!");
        }
        try {
            if (message.getSOAPHeader() != null) {
                soapRequest.setSoapHeader(getSoapHeader(message.getSOAPHeader()));
            }
            soapRequest.setAction(checkSoapAction(soapAction, soapRequest.getSoapHeader()));
            soapRequest.setSoapBodyContent(getBodyContent((EnvelopeDocument) doc));
        } catch (SOAPException soape) {
            throw new NoApplicableCodeException().causedBy(soape).withMessage("Error while parsing SOAPMessage!");
        }
    } catch (OwsExceptionReport owse) {
        throw new DecodingException(owse);
    }
    return soapRequest;
}
Also used : SoapRequest(org.n52.shetland.w3c.soap.SoapRequest) EnvelopeDocument(org.w3.x2003.x05.soapEnvelope.EnvelopeDocument) NoApplicableCodeException(org.n52.shetland.ogc.ows.exception.NoApplicableCodeException) SOAPException(javax.xml.soap.SOAPException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) IOException(java.io.IOException) SOAPMessage(javax.xml.soap.SOAPMessage) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Aggregations

NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)11 IOException (java.io.IOException)5 DecodingException (org.n52.svalbard.decode.exception.DecodingException)5 OwsDecodingException (org.n52.iceland.coding.decode.OwsDecodingException)3 OwsEncodingException (org.n52.iceland.coding.encode.OwsEncodingException)3 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)3 SOAPException (javax.xml.soap.SOAPException)2 SOAPMessage (javax.xml.soap.SOAPMessage)2 OwsOperationKey (org.n52.shetland.ogc.ows.service.OwsOperationKey)2 SoapRequest (org.n52.shetland.w3c.soap.SoapRequest)2 SoapResponse (org.n52.shetland.w3c.soap.SoapResponse)2 XmlStringOperationDecoderKey (org.n52.svalbard.decode.XmlStringOperationDecoderKey)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 EXIFactory (com.siemens.ct.exi.EXIFactory)1 EXISource (com.siemens.ct.exi.api.sax.EXISource)1 EXIException (com.siemens.ct.exi.exceptions.EXIException)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 List (java.util.List)1