Package org.apache.servicemix.soap.api

Examples of org.apache.servicemix.soap.api.Fault


            if (xmlReader.nextTag() == XMLStreamConstants.END_ELEMENT) {
                // Empty body
                message.setContent(XMLStreamReader.class, null);
            }
        } catch (XMLStreamException e) {
            throw new Fault(e);
        }
    }
View Full Code Here


            MessageExchange me = message.getContent(MessageExchange.class);
            Binding binding = message.get(Binding.class);
            Operation operation = binding.getOperation(me.getOperation());
            if (operation != null) {
                if (!me.getPattern().equals(operation.getMep())) {
                    throw new Fault("Received incorrect exchange mep.  Received " + me.getPattern()
                                    + " but expected " + operation.getMep() + " for operation "
                                    + operation.getName());
                }
                message.put(Operation.class, operation);
                if (operation instanceof SoapOperation<?>) {
View Full Code Here

                } else {
                    throw new IllegalStateException("Unrecognized soap version: " + soapVersion.getVersion());
                }
            }
        } catch (XMLStreamException e) {
            throw new Fault(e);
        }
    }
View Full Code Here

        }
        Source source = message.getContent(Source.class);
        Element element = DomUtil.parse(source).getDocumentElement();
        if (!JbiConstants.WSDL11_WRAPPER_NAMESPACE.equals(element.getNamespaceURI()) ||
            !JbiConstants.WSDL11_WRAPPER_MESSAGE_LOCALNAME.equals(element.getLocalName())) {
            throw new Fault("Message wrapper element is '" + QNameUtil.toString(element)
                    + "' but expected '{" + JbiConstants.WSDL11_WRAPPER_NAMESPACE + "}message'");
        }
        List<NodeList> partsContent = new ArrayList<NodeList>();
        Element partWrapper = DomUtil.getFirstChildElement(element);
        while (partWrapper != null) {
            if (!JbiConstants.WSDL11_WRAPPER_NAMESPACE.equals(element.getNamespaceURI()) ||
                !JbiConstants.WSDL11_WRAPPER_PART_LOCALNAME.equals(partWrapper.getLocalName())) {
                throw new Fault("Unexpected part wrapper element '" + QNameUtil.toString(partWrapper)
                        + "' expected '{" + JbiConstants.WSDL11_WRAPPER_NAMESPACE + "}part'");
            }
            NodeList nodes = partWrapper.getChildNodes();
            partsContent.add(nodes);
            partWrapper = DomUtil.getNextSiblingElement(partWrapper);
        }
       
        Wsdl1SoapOperation wsdlOperation = getOperation(message);
        Wsdl1SoapMessage wsdlMessage = server ? wsdlOperation.getOutput() : wsdlOperation.getInput();
        Collection orderedParts = wsdlMessage.getParts();
        if (orderedParts.size() != partsContent.size()) {
            throw new Fault("Message contains " + partsContent.size() + " part(s) but expected "
                    + orderedParts.size() + " parts");
        }
       
        Document document = DomUtil.createDocument();
        Node body = null;
        if (wsdlOperation.getStyle() == Style.RPC) {
            body = DomUtil.createElement(document, wsdlMessage.getElementName());
        }
        int idxPart = 0;
        for (Wsdl1SoapPart part : wsdlMessage.getParts()) {
            NodeList nodes =  partsContent.get(idxPart++);
            if (part.isBody()) {
                if (wsdlOperation.getStyle() == Style.DOCUMENT) {
                    Element e = null;
                    for (int i = 0; i < nodes.getLength(); i++) {
                        Node n = nodes.item(i);
                        if (n instanceof Element) {
                            if (e != null) {
                                throw new Fault("Body part '" + part.getName() + "' contains more than one element; expected a single element.");
                            } else {
                                e = (Element) n;
                            }
                        }
                    }
                    if (e == null) {
                        throw new Fault("Body part '" + part.getName() + "' contains no element; expected a single element.");
                    }
                    if (!wsdlMessage.getElementName().equals(DomUtil.getQName(e))) {
                        throw new Fault("Body part '" + part.getName() + "' element '" + DomUtil.getQName(e) + " doesn't match expected element '" + QNameUtil.toString(wsdlMessage.getElementName()) + "'");
                    }
                    body = document.importNode(e, true);
                    document.appendChild(body);
                } else /* rpc-style */ {
                    for (int j = 0; j < nodes.getLength(); j++) {
                        /* note: we don't do any validation on RPC-style part value types */
                        Element e = document.createElementNS(wsdlMessage.getElementName().getNamespaceURI(), part.getName());
                        body.appendChild(e);
                        e.appendChild(document.importNode(nodes.item(j), true));
                    }
                }
            } else {
                DocumentFragment frag = document.createDocumentFragment();
                Element e = null;
                for (int i = 0; i < nodes.getLength(); i++) {
                    Node n = nodes.item(i);
                    if (n instanceof Element) {
                        if (e != null) {
                            throw new Fault("Header part '" + part.getName() + "' contains more than one element; expected a single element.");
                        } else {
                            e = (Element) n;
                        }
                    }
                }
                if (e == null) {
                    throw new Fault("Header part '" + part.getName() + "' contains no element; expected a single element.");
                }
                QName headerName = part.getElement();
                if (!headerName.equals(DomUtil.getQName(e))) {
                    throw new Fault("Header part '" + part.getName() + "' element '" + DomUtil.getQName(e) + " doesn't match expected element '" + QNameUtil.toString(headerName) + "'");
                }
                for (int j=0; j<nodes.getLength(); j++) {
                    frag.appendChild(document.importNode(nodes.item(j), true));
                }
                message.getSoapHeaders().put(headerName, frag);
View Full Code Here

    }

    protected Wsdl1SoapOperation getOperation(Message message) {
        Operation operation = message.get(Operation.class);
        if (operation == null) {
            throw new Fault("Operation not bound on this message");
        }
        if (operation instanceof Wsdl1SoapOperation == false) {
            throw new Fault("Message is not bound to a WSDL 1.1 SOAP operation");
        }
        return (Wsdl1SoapOperation) operation;
    }
View Full Code Here

    }
   
    protected Wsdl1SoapMessage getMessage(Message message) {
        org.apache.servicemix.soap.api.model.Message msg = message.get(org.apache.servicemix.soap.api.model.Message.class);
        if (msg == null) {
            throw new Fault("Message not bound on this message");
        }
        if (msg instanceof Wsdl1SoapMessage == false) {
            throw new Fault("Message is not bound to a WSDL 1.1 SOAP operation message");
        }
        return (Wsdl1SoapMessage) msg;
    }
View Full Code Here

            chain.doIntercept(message);
            // Close elements
            writer.writeEndElement();
            writer.writeEndElement();
        } catch (XMLStreamException e) {
            throw new Fault(e);
        }
    }
View Full Code Here

    public static WSDLFactory getWSDL11Factory() {
        if (wsdl11Factory == null) {
            try {
                wsdl11Factory = WSDLFactory.newInstance();
            } catch (WSDLException e) {
                throw new Fault(e);
            }
        }
        return wsdl11Factory;
    }
View Full Code Here

            return;
        }
        Wsdl2HttpBinding httpBinding = (Wsdl2HttpBinding) binding;
        String uri = message.getTransportHeaders().get(HttpConstants.REQUEST_URI);
        if (uri == null) {
            throw new Fault("Transport header not set: " + HttpConstants.REQUEST_URI);
        }
        String mth = message.getTransportHeaders().get(HttpConstants.REQUEST_METHOD);
        if (mth == null) {
            throw new Fault("Transport header not set: " + HttpConstants.REQUEST_METHOD);
        }
        for (Wsdl2HttpOperation operation : httpBinding.getOperations()) {
            if (mth.equalsIgnoreCase(operation.getHttpMethod())) {
                String loc = IriDecoderHelper.combine(binding.getLocation(), operation.getHttpLocation());
                String path1 = getUriPath(uri);
View Full Code Here

            int len;
            while ((len = in.read(buffer)) >= 0) {
                out.write(buffer, 0, len);
            }
        } catch (IOException e) {
            throw new Fault(e);
        } finally {
            close(in);
            close(out);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.soap.api.Fault

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.