Package org.apache.servicemix.soap.bindings.soap

Examples of org.apache.servicemix.soap.bindings.soap.SoapFault


                soapVersion = SoapVersionFactory.getInstance().getSoapVersion(name);
            } else {
                soapVersion = soapVersion.getDerivedVersion(name.getPrefix());
            }
            if (soapVersion == null) {
                throw new SoapFault(SoapConstants.SOAP_12_CODE_VERSIONMISMATCH, "Unrecognized namespace: "
                                + xmlReader.getNamespaceURI() + " at ["
                                + xmlReader.getLocation().getLineNumber() + ","
                                + xmlReader.getLocation().getColumnNumber()
                                + "]. Expecting a Soap 1.1 or 1.2 namespace.");
            }
            message.put(SoapVersion.class, soapVersion);
            if (!name.equals(soapVersion.getEnvelope())) {
                if (name.getLocalPart().equals(soapVersion.getEnvelope().getLocalPart())) {
                    throw new SoapFault(SoapConstants.SOAP_12_CODE_VERSIONMISMATCH,
                          "Expected a SOAP " + soapVersion.getVersion() + " request");
                }
                throw new SoapFault(SoapConstants.SOAP_12_CODE_VERSIONMISMATCH, "Unrecognized element: "
                                + xmlReader.getName() + " at ["
                                + xmlReader.getLocation().getLineNumber() + ","
                                + xmlReader.getLocation().getColumnNumber()
                                + "]. Expecting 'Envelope'.");
            }
            xmlReader.nextTag();
            if (xmlReader.getName().equals(soapVersion.getHeader())) {
                Map<QName, DocumentFragment> headers = message.getSoapHeaders();
                while (xmlReader.nextTag() != XMLStreamConstants.END_ELEMENT) {
                    QName hn = xmlReader.getName();
                    Element e = StaxUtil.createElement(xmlReader);
                    DocumentFragment df = headers.get(hn);
                    if (df == null) {
                        df = e.getOwnerDocument().createDocumentFragment();
                    }
                    e = (Element) df.getOwnerDocument().importNode(e, true);
                    df.appendChild(e);
                    headers.put(hn, df);
                }
                xmlReader.nextTag();
            }
            if (!xmlReader.getName().equals(soapVersion.getBody())) {
                throw new SoapFault(SoapFault.SENDER, "Unrecognized element: "
                                + xmlReader.getName() + ". Expecting 'Body'.");
            }
            if (xmlReader.nextTag() == XMLStreamConstants.END_ELEMENT) {
                // Empty body
                message.setContent(XMLStreamReader.class, null);
View Full Code Here


                if (sb.length() > 0) {
                    sb.append(", ");
                }
                sb.append(qname.toString());
            }
            throw new SoapFault(SoapConstants.SOAP_12_CODE_MUSTUNDERSTAND, sb.toString());
        }
    }
View Full Code Here

            for (Operation<?> oper : binding.getOperations()) {
                sb.append("  - ");
                sb.append(oper.getInput().getElementName());
                sb.append("\n");
            }
            throw new SoapFault(SoapFault.SENDER, sb.toString());
        }
    }
View Full Code Here

        Exception exception = message.getContent(Exception.class);
        XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
        SoapVersion soapVersion = message.get(SoapVersion.class);
        try {
            if (exception instanceof SoapFault) {
                SoapFault fault = (SoapFault) exception;
                if (soapVersion == null) {
                    soapVersion = Soap11.getInstance();
                }
                if (soapVersion.getVersion() == 1.1) {
                    writeSoap11Fault(writer, fault, soapVersion);
View Full Code Here

        if (!soapVersion.getFault().equals(xmlReader.getName())) {
            return;
        }
        // Read fault as DOM
        Element el = StaxUtil.createElement(xmlReader);
        SoapFault fault = readFault(el);
        message.setContent(Exception.class, fault);
    }
View Full Code Here

                Element subchild = DomUtil.getFirstChildElement(child);
                if (subchild != null) {
                    details = new DOMSource(subchild);
                    subchild = DomUtil.getNextSiblingElement(subchild);
                    if (subchild != null) {
                        throw new SoapFault(SoapFault.RECEIVER, "Multiple elements are not supported in Detail");
                    }
                }
                child = DomUtil.getNextSiblingElement(child);
                childname = DomUtil.getQName(child);
            }
            // Nothing should be left
            if (childname != null) {
                throw new SoapFault(SoapFault.SENDER, "Unexpected element: " + childname);
            }
        // Parse soap 1.2 faults
        } else {
            // Fault code
            Element child = DomUtil.getFirstChildElement(element);
            checkElementName(child, SoapConstants.SOAP_12_FAULTCODE);
            Element subchild = DomUtil.getFirstChildElement(child);
            checkElementName(subchild, SoapConstants.SOAP_12_FAULTVALUE);
            code = DomUtil.createQName(subchild, DomUtil.getElementText(subchild));
            if (!SoapConstants.SOAP_12_CODE_DATAENCODINGUNKNOWN.equals(code) &&
                !SoapConstants.SOAP_12_CODE_MUSTUNDERSTAND.equals(code) &&
                !SoapConstants.SOAP_12_CODE_RECEIVER.equals(code) &&
                !SoapConstants.SOAP_12_CODE_SENDER.equals(code) &&
                !SoapConstants.SOAP_12_CODE_VERSIONMISMATCH.equals(code)) {
                throw new SoapFault(SoapFault.SENDER, "Unexpected fault code: " + code);
            }
            subchild = DomUtil.getNextSiblingElement(subchild);
            if (subchild != null) {
                checkElementName(subchild, SoapConstants.SOAP_12_FAULTSUBCODE);
                Element subsubchild = DomUtil.getFirstChildElement(subchild);
                checkElementName(subsubchild, SoapConstants.SOAP_12_FAULTVALUE);
                subcode = DomUtil.createQName(subsubchild, DomUtil.getElementText(subsubchild));
                subsubchild = DomUtil.getNextSiblingElement(subsubchild);
                if (subsubchild != null) {
                    checkElementName(subsubchild, SoapConstants.SOAP_12_FAULTSUBCODE);
                    throw new SoapFault(SoapFault.RECEIVER, "Unsupported nested subcodes");
                }
            }
            // Fault reason
            child = DomUtil.getNextSiblingElement(child);
            checkElementName(child, SoapConstants.SOAP_12_FAULTREASON);
            subchild = DomUtil.getFirstChildElement(child);
            checkElementName(subchild, SoapConstants.SOAP_12_FAULTTEXT);
            reason = DomUtil.getElementText(subchild);
            subchild = DomUtil.getNextSiblingElement(subchild);
            if (subchild != null) {
                throw new SoapFault(SoapFault.RECEIVER, "Unsupported multiple reasons");
            }
            // Fault node
            child = DomUtil.getNextSiblingElement(child);
            QName childname = DomUtil.getQName(child);
            if (SoapConstants.SOAP_12_FAULTNODE.equals(childname)) {
                node = URI.create(DomUtil.getElementText(child));
                child = DomUtil.getNextSiblingElement(child);
                childname = DomUtil.getQName(child);
            }
            // Fault role
            if (SoapConstants.SOAP_12_FAULTROLE.equals(childname)) {
                role = URI.create(DomUtil.getElementText(child));
                child = DomUtil.getNextSiblingElement(child);
                childname = DomUtil.getQName(child);
            }
            // Fault details
            if (SoapConstants.SOAP_12_FAULTDETAIL.equals(childname)) {
                subchild = DomUtil.getFirstChildElement(child);
                if (subchild != null) {
                    details = new DOMSource(subchild);
                    subchild = DomUtil.getNextSiblingElement(subchild);
                    if (subchild != null) {
                        throw new SoapFault(SoapFault.RECEIVER, "Multiple elements are not supported in Detail");
                    }
                }
                child = DomUtil.getNextSiblingElement(child);
                childname = DomUtil.getQName(child);
            }
            // Nothing should be left
            if (childname != null) {
                throw new SoapFault(SoapFault.SENDER, "Unexpected element: " + childname);
            }
        }
        return new SoapFault(code, subcode, reason, node, role, details);
    }
View Full Code Here

    }
   
    private void checkElementName(Element element, QName expected) throws SoapFault {
        QName name= DomUtil.getQName(element);
        if (!expected.equals(name)) {
            throw new SoapFault(SoapFault.SENDER, "Expected element: " + expected + " but found " + name);
        }           
    }
View Full Code Here

public class JbiFaultOutInterceptor extends AbstractInterceptor {

    public void handleMessage(Message message) {
        NormalizedMessage nm = message.getContent(NormalizedMessage.class);
        if (nm instanceof Fault) {
            SoapFault fault = createFault(nm);
            throw fault;
        }
    }
View Full Code Here

        QName code = (QName) nm.getProperty(JbiConstants.SOAP_FAULT_CODE);
        QName subcode = (QName) nm.getProperty(JbiConstants.SOAP_FAULT_SUBCODE);
        String reason = (String) nm.getProperty(JbiConstants.SOAP_FAULT_REASON);
        URI node = (URI) nm.getProperty(JbiConstants.SOAP_FAULT_NODE);
        URI role = (URI) nm.getProperty(JbiConstants.SOAP_FAULT_ROLE);
        SoapFault fault = new SoapFault(code, subcode, reason, node, role, src);
        return fault;
    }
View Full Code Here

    private void getContent(NormalizedMessage nm, Message message) throws MessagingException {
        Exception e = message.getContent(Exception.class);
        if (e == null) {
            nm.setContent(message.getContent(Source.class));
        } else if (e instanceof SoapFault) {
            SoapFault fault = (SoapFault) e;
            nm.setContent(fault.getDetails());
            nm.setProperty(JbiConstants.SOAP_FAULT_CODE, fault.getCode());
            nm.setProperty(JbiConstants.SOAP_FAULT_NODE, fault.getNode());
            nm.setProperty(JbiConstants.SOAP_FAULT_REASON, fault.getReason());
            nm.setProperty(JbiConstants.SOAP_FAULT_ROLE, fault.getRole());
            nm.setProperty(JbiConstants.SOAP_FAULT_SUBCODE, fault.getSubcode());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.soap.bindings.soap.SoapFault

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.