Search in sources :

Example 1 with SoapFault

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

the class Soap11Decoder method createFault.

@Override
protected SoapRequest createFault(DecodingException de) {
    SoapFault fault = new SoapFault();
    fault.setFaultCode(QN_CLIENT);
    fault.setLocale(Locale.ENGLISH);
    fault.setFaultReason(de.getMessage());
    SoapRequest r = new SoapRequest(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE, SOAPConstants.SOAP_1_1_PROTOCOL);
    r.setSoapFault(fault);
    return r;
}
Also used : SoapFault(org.n52.shetland.w3c.soap.SoapFault) SoapRequest(org.n52.shetland.w3c.soap.SoapRequest)

Example 2 with SoapFault

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

the class Soap12Decoder method createFault.

@Override
protected SoapRequest createFault(DecodingException de) {
    SoapFault fault = new SoapFault();
    fault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
    fault.setLocale(Locale.ENGLISH);
    fault.setFaultReason(de.getMessage());
    SoapRequest r = new SoapRequest(SOAPConstants.URI_NS_SOAP_1_2_ENVELOPE, SOAPConstants.SOAP_1_2_PROTOCOL);
    r.setSoapFault(fault);
    return r;
}
Also used : SoapFault(org.n52.shetland.w3c.soap.SoapFault) SoapRequest(org.n52.shetland.w3c.soap.SoapRequest)

Example 3 with SoapFault

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

the class AbstractSoapEncoder method createSOAPFaultFromExceptionResponse.

/**
 * Creates a SOAPFault element from SOS exception
 *
 * @param soapFault          SOAPFault element
 * @param owsExceptionReport SOS exception
 *
 * @return SOAP action URI.
 *
 * @throws SOAPException if an error occurs.
 */
protected String createSOAPFaultFromExceptionResponse(SOAPFault soapFault, OwsExceptionReport owsExceptionReport) throws SOAPException {
    // exceptions!
    if (!owsExceptionReport.getExceptions().isEmpty()) {
        CodedException firstException = owsExceptionReport.getExceptions().iterator().next();
        if (soapFault.getNamespaceURI().equalsIgnoreCase(SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
            QName qname = new QName(soapFault.getNamespaceURI(), "Client", soapFault.getPrefix());
            soapFault.setFaultCode(qname);
        } else {
            soapFault.setFaultCode(SOAPConstants.SOAP_SENDER_FAULT);
            if (firstException.getCode() != null) {
                soapFault.appendFaultSubcode(new QName(OWSConstants.NS_OWS, firstException.getCode().toString(), OWSConstants.NS_OWS_PREFIX));
            } else {
                soapFault.appendFaultSubcode(OWSConstants.QN_NO_APPLICABLE_CODE);
            }
        }
        soapFault.addFaultReasonText(SoapHelper.getSoapFaultReasonText(firstException.getCode()), Locale.ENGLISH);
        Detail detail = soapFault.addDetail();
        for (CodedException exception : owsExceptionReport.getExceptions()) {
            createSOAPFaultDetail(detail, exception);
        }
        return getExceptionActionURI(firstException.getCode());
    } else {
        SoapFault fault = new SoapFault();
        fault.setFaultCode(SOAPConstants.SOAP_RECEIVER_FAULT);
        fault.setFaultSubcode(OWSConstants.QN_NO_APPLICABLE_CODE);
        fault.setFaultReason(DEFAULT_FAULT_REASON);
        fault.setLocale(Locale.ENGLISH);
        fault.setDetailText(MISSING_EXCEPTION_DETAIL_TEXT);
        createSOAPFault(soapFault, fault);
        return SosSoapConstants.RESP_ACTION_SOS;
    }
}
Also used : SoapFault(org.n52.shetland.w3c.soap.SoapFault) CodedException(org.n52.shetland.ogc.ows.exception.CodedException) QName(javax.xml.namespace.QName) Detail(javax.xml.soap.Detail)

Example 4 with SoapFault

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

the class AbstractSoapEncoder method createSOAPBody.

/**
 * Creates a SOAPBody element from SOS response
 *
 * @param soapResponseMessage SOAPBody element
 * @param sosResponse         SOS response
 * @param actionURI           the action URI
 *
 * @return the action URI
 *
 * @throws SOAPException if an error occurs.
 */
protected String createSOAPBody(SOAPMessage soapResponseMessage, XmlObject sosResponse, String actionURI) throws SOAPException {
    if (sosResponse != null) {
        addAndRemoveSchemaLocationForSOAP(sosResponse, soapResponseMessage);
        soapResponseMessage.getSOAPBody().addDocument((Document) sosResponse.getDomNode());
        return actionURI;
    } else {
        SoapFault fault = new SoapFault();
        fault.setFaultCode(SOAPConstants.SOAP_RECEIVER_FAULT);
        fault.setFaultSubcode(new QName(OWSConstants.NS_OWS, OwsExceptionCode.NoApplicableCode.name(), OWSConstants.NS_OWS_PREFIX));
        fault.setFaultReason(DEFAULT_FAULT_REASON);
        fault.setLocale(Locale.ENGLISH);
        fault.setDetailText(MISSING_RESPONSE_DETAIL_TEXT);
        createSOAPFault(soapResponseMessage.getSOAPBody().addFault(), fault);
    }
    return null;
}
Also used : SoapFault(org.n52.shetland.w3c.soap.SoapFault) QName(javax.xml.namespace.QName)

Example 5 with SoapFault

use of org.n52.shetland.w3c.soap.SoapFault 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)

Aggregations

SoapFault (org.n52.shetland.w3c.soap.SoapFault)6 SoapRequest (org.n52.shetland.w3c.soap.SoapRequest)3 QName (javax.xml.namespace.QName)2 IOException (java.io.IOException)1 Detail (javax.xml.soap.Detail)1 SOAPException (javax.xml.soap.SOAPException)1 SOAPMessage (javax.xml.soap.SOAPMessage)1 XmlString (org.apache.xmlbeans.XmlString)1 CodedException (org.n52.shetland.ogc.ows.exception.CodedException)1 NoApplicableCodeException (org.n52.shetland.ogc.ows.exception.NoApplicableCodeException)1 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1 Fault (org.w3.x2003.x05.soapEnvelope.Fault)1 FaultDocument (org.w3.x2003.x05.soapEnvelope.FaultDocument)1 Reasontext (org.w3.x2003.x05.soapEnvelope.Reasontext)1