Package org.apache.ws.commons.soap

Examples of org.apache.ws.commons.soap.SOAPEnvelope


     * @param opName
     * @param toSend
     * @throws AxisFault
     */
    public void send(String opName, OMElement toSend) throws AxisFault {
        SOAPEnvelope envelope = createDefaultSOAPEnvelope();

        if (toSend != null) {
            envelope.getBody().addChild(toSend);
        }

        this.send(opName, envelope);
    }
View Full Code Here


                OMElement bodyContent;

                SOAPFactory fac = getSOAPFactory(msgContext);
                bodyContent = result;

                SOAPEnvelope envelope = fac.getDefaultEnvelope();

                if (bodyContent != null) {
                    envelope.getBody().addChild(bodyContent);
                }

                newmsgContext.setEnvelope(envelope);
            } else {
                throw new AxisFault(Messages.getMessage("methodNotImplemented",
View Full Code Here

     */
    private void fillSoapEnvelope(MessageContext mc, OMElement elem)
            throws AxisFault {
        mc.setServiceContext(serviceContext);
        SOAPFactory sf = getSOAPFactory();
        SOAPEnvelope se = sf.getDefaultEnvelope();
        if (elem != null) {
            se.getBody().addChild(elem);
        }
        if (headers != null) {
            SOAPHeader sh = se.getHeader();
            for (int i = 0; i < headers.size(); i++) {
                sh.addChild((OMElement) headers.get(i));
            }
        }
        mc.setEnvelope(se);
View Full Code Here

        } else {
            if (block) {
                // Send the SOAP Message and receive a response
                MessageContext response = send(mc);
                // check for a fault and return the result
                SOAPEnvelope resenvelope = response.getEnvelope();
                if (resenvelope.getBody().hasFault()) {
                    SOAPFault soapFault = resenvelope.getBody().getFault();
                    Exception ex = soapFault.getException();
                    if (options.isExceptionToBeThrownOnSOAPFault()) {
                        // does the SOAPFault has a detail element for Excpetion
                        if (ex != null) {
                            throw new AxisFault(ex);
View Full Code Here

        // If request is REST we assume the responseMessageContext is REST, so
        // set the variable


        SOAPEnvelope resenvelope = TransportUtils.createSOAPMessage(
                responseMessageContext, msgctx.getEnvelope().getNamespace()
                .getName());
        if (resenvelope != null) {
            responseMessageContext.setEnvelope(resenvelope);
            engine = new AxisEngine(msgctx.getConfigurationContext());
View Full Code Here

        public void run() {
            try {
                // send the request and wait for reponse
                MessageContext response = send(msgctx);
                // call the callback
                SOAPEnvelope resenvelope = response.getEnvelope();
                SOAPBody body = resenvelope.getBody();
                if (body.hasFault()) {
                    Exception ex = body.getFault().getException();

                    if (ex != null) {
                        callback.onError(ex);
View Full Code Here

            msgCtx.setProperty(MessageContext.TRANSPORT_OUT, sender.getResponse());

            XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(
                    new BufferedReader(new InputStreamReader(in)));
            StAXBuilder builder = new StAXSOAPModelBuilder(reader, null);
            SOAPEnvelope envelope = (SOAPEnvelope) builder.getDocumentElement();

            msgCtx.setEnvelope(envelope);

            AxisEngine engine = new AxisEngine(confContext);

            if (envelope.getBody().hasFault()) {
                engine.receiveFault(msgCtx);
            } else {
                engine.receive(msgCtx);
            }
        } catch (XMLStreamException e) {
View Full Code Here

        super.setUp();
        factory = OMAbstractFactory.getSOAP11Factory();
    }

    public void testOptimizedEnvelope() {
        SOAPEnvelope soapEnvelope = factory.getDefaultEnvelope();

        OMElement element = factory.createOMElement(
                new QName("MyFirstBodyElement"), soapEnvelope.getBody());
        OMElement element11 = factory.createOMElement(
                new QName("MyFirstBodyElement"), element);
        OMText optimizedText = factory.createText("Hi", "text/plain", true);
        element11.addChild(optimizedText);
        assertTrue(
View Full Code Here

                "optmization check has not performed correctly in SOAPEnvelope",
                HTTPTransportUtils.checkEnvelopeForOptimise(soapEnvelope));
    }

    public void testNonOptimizedEnvelope() {
        SOAPEnvelope soapEnvelope = factory.getDefaultEnvelope();

        OMElement element = factory.createOMElement(
                new QName("MyFirstBodyElement"), soapEnvelope.getBody());
        OMElement element11 = factory.createOMElement(
                new QName("MyFirstBodyElement"), element);
        OMText optimizedText = factory.createText("Hi", "text/plain", false);
        element11.addChild(optimizedText);
        assertFalse(
View Full Code Here

            if(service==null){
                throw  new AxisFault("service not found: " + srvice);
            }
            String operation = values[1];
            SOAPFactory soapFactory = new SOAP11Factory();
            SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
//            OMNamespace omNs = soapFactory.createOMNamespace(values[0], "services");
            OMNamespace omNs = soapFactory.createOMNamespace(service.getSchematargetNamespace(),
                    service.getSchematargetNamespacePrefix());
            //OMNamespace defualtNs = new OMNamespaceImpl("", null, soapFactory);
            OMNamespace defualtNs = soapFactory.createOMNamespace(service.getSchematargetNamespace(),
                    service.getSchematargetNamespacePrefix());
            OMElement opElement = soapFactory.createOMElement(operation, omNs);
            Iterator it = map.keySet().iterator();

            while (it.hasNext()) {
                String name = (String) it.next();
                String value = (String) map.get(name);
                OMElement omEle = soapFactory.createOMElement(name, omNs);

                omEle.setText(value);
                opElement.addChild(omEle);
            }

            envelope.getBody().addChild(opElement);

            return envelope;
        } else {
            return null;
        }
View Full Code Here

TOP

Related Classes of org.apache.ws.commons.soap.SOAPEnvelope

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.