Package org.apache.axiom.soap

Examples of org.apache.axiom.soap.SOAPEnvelope


*/
public class IterateMediatorTest extends AbstractSplitMediatorTestCase {

    protected void setUp() throws Exception {
        super.setUp();
        SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
        envelope.getBody().addChild(createOMElement("<original>" +
            "<itr>test-split-context-itr1-body</itr>" + "<itr>test-split-context-itr2-body</itr>" +
            "</original>"));
        testCtx.setEnvelope(envelope);
        fac = new IterateMediatorFactory();
    }
View Full Code Here


        // invoke transformation, with static enveope
        MessageContext synCtx = TestUtils.getAxis2MessageContext(
                "<empty/>", new HashMap<String, Entry>());
        faultMediator.mediate(synCtx);

        SOAPEnvelope envelope = synCtx.getEnvelope();
        SOAPFault fault = envelope.getBody().getFault();
        assertTrue(F_CODE.equals(fault.getCode().getTextAsQName()));
        assertTrue(F_STRING.equals(fault.getReason().getText()));
        assertTrue(F_ACTOR_URI.equals(fault.getRole().getRoleValue()));
        assertTrue(F_DETAIL.equals(fault.getDetail().getText()));
        assertEquals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI, envelope.getNamespace().getNamespaceURI());
    }
View Full Code Here

        org.apache.axis2.context.MessageContext mc =
                new org.apache.axis2.context.MessageContext();
        SynapseEnvironment env = new Axis2SynapseEnvironment(config);
        MessageContext synMc = new Axis2MessageContext(mc, config, env);
        SOAPEnvelope envelope =
                OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
        OMDocument omDoc =
                OMAbstractFactory.getSOAP11Factory().createOMDocument();
        omDoc.addChild(envelope);

        envelope.getBody().addChild(createOMElement(payload));

        synMc.setEnvelope(envelope);
        return synMc;
    }
View Full Code Here

            config.setAxisConfiguration(axisConfig);
        }
        ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
        SynapseEnvironment env = new Axis2SynapseEnvironment(cfgCtx, config);
        MessageContext synMc = new Axis2MessageContext(mc, config, env);
        SOAPEnvelope envelope =
                OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
        OMDocument omDoc =
                OMAbstractFactory.getSOAP11Factory().createOMDocument();
        omDoc.addChild(envelope);

        envelope.getBody().addChild(createOMElement(payload));

        synMc.setEnvelope(envelope);
        return synMc;
    }
View Full Code Here

    }

    public static void addSOAPHeaderBlock(org.apache.axis2.context.MessageContext msgCtx,
                                          QName qname, String value) {

        SOAPEnvelope env = msgCtx.getEnvelope();
        SOAPHeaderBlock header = env.getHeader().addHeaderBlock(
                qname.getLocalPart(),
                msgCtx.getEnvelope().getOMFactory().
                        createOMNamespace(qname.getNamespaceURI(), qname.getPrefix()));
        header.setText(value);       
    }
View Full Code Here

                                new AxisFault(errorMessage);

                        MessageContext nioFaultMessageContext =
                            MessageContextBuilder.createFaultMessageContext(mc, axisFault);

                        SOAPEnvelope envelope = nioFaultMessageContext.getEnvelope();

                        if (log.isDebugEnabled()) {
                            log.debug("Sending Fault for Request with Message ID : "
                                    + mc.getMessageID());
                        }
                       
                        nioFaultMessageContext.setProperty(
                            NhttpConstants.SENDING_FAULT, Boolean.TRUE);
                        nioFaultMessageContext.setProperty(
                                NhttpConstants.ERROR_MESSAGE, errorMessage);
                        if (errorCode != -1) {
                            nioFaultMessageContext.setProperty(
                                NhttpConstants.ERROR_CODE, errorCode);
                        }
                        if (exceptionToRaise != null) {
                            nioFaultMessageContext.setProperty(
                                NhttpConstants.ERROR_DETAIL, exceptionToRaise.toString());
                            nioFaultMessageContext.setProperty(
                                NhttpConstants.ERROR_EXCEPTION, exceptionToRaise);
                            envelope.getBody().getFault().getDetail().setText(
                                exceptionToRaise.toString());
                        } else {
                            nioFaultMessageContext.setProperty(
                                NhttpConstants.ERROR_DETAIL, errorMessage);
                            envelope.getBody().getFault().getDetail().setText(errorMessage);
                        }
                        nioFaultMessageContext.setProperty(CLIENT_CONNECTION_DEBUG,
                            mc.getProperty(CLIENT_CONNECTION_DEBUG));
                        mr.receive(nioFaultMessageContext);
View Full Code Here

                } else if (SynapseConstants.HEADER_REPLY_TO.equals(qName.getLocalPart())) {
                    synCtx.setReplyTo(null);
                } else if (SynapseConstants.HEADER_RELATES_TO.equals(qName.getLocalPart())) {
                    synCtx.setRelatesTo(null);
                } else {
                    SOAPEnvelope envelope = synCtx.getEnvelope();
                    if (envelope != null) {
                        SOAPHeader header = envelope.getHeader();
                        if (header != null) {
                            removeFromHeaderList(header.
                                getHeaderBlocksWithNSURI(""));
                        }
                    }
                }

            } else {
                SOAPEnvelope envelope = synCtx.getEnvelope();
                if (envelope != null) {
                    SOAPHeader header = envelope.getHeader();
                    if (header != null) {
                        removeFromHeaderList(header.
                            getHeaderBlocksWithNSURI(qName.getNamespaceURI()));
                    }
                }
View Full Code Here

        synLog.traceOrDebug("End : Header mediator");
        return true;
    }

    private void addCustomHeader(MessageContext synCtx, String value) {
        SOAPEnvelope env = synCtx.getEnvelope();
        if (env == null) {
            return;
        }
        SOAPFactory fac = (SOAPFactory) env.getOMFactory();
        SOAPHeader header = env.getHeader();
        if (header == null) {
            header = fac.createSOAPHeader(env);
        }
        SOAPHeaderBlock hb = header.addHeaderBlock(qName.getLocalPart(),
                fac.createOMNamespace(qName.getNamespaceURI(), qName.getPrefix()));
View Full Code Here

    public void testGetText() {
        try {
            SOAPModelBuilder soapBuilder = getOMBuilder(
                    "soap/OMElementTest.xml");
            SOAPEnvelope soapEnvelope = (SOAPEnvelope) soapBuilder.getDocumentElement();
            OMElement wsaTo = soapEnvelope.getHeader().getFirstChildWithName(
                    new QName(WSA_URI, WSA_TO));

            String expectedString = "http://localhost:8081/axis/services/BankPort";
            assertEquals("getText is not returning the correct value",
                         wsaTo.getText().trim(),
View Full Code Here

   
    // Read XML
    InputStream is = getTestResource(TestConstants.TEST);
   
    // Build SOAP OM
    SOAPEnvelope env1 = createEnvelope(is);
   
    // Add illegal character
    SOAPBody body = env1.getBody();
    OMElement omElement = body.getFirstElement();
    String text = omElement.getText();
    text = text + "[" + insert + "]";
    System.out.println("New Text = " + text);
    omElement.setText(text);
   
    // Serialize
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    OMOutputFormat omFormat = new OMOutputFormat();
    omFormat.setXmlStreamWriterFilter(new XMLStreamWriterRemoveIllegalChars());
    env1.serialize(baos, omFormat);
   
    String xmlText = baos.toString();
    System.out.println("Serialized Text = " + xmlText);
   
    ByteArrayInputStream bais = new ByteArrayInputStream(xmlText.getBytes("UTF-8"));
   
    SOAPEnvelope env2 = createEnvelope(bais);
    env2.build();
  }
View Full Code Here

TOP

Related Classes of org.apache.axiom.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.