Search in sources :

Example 71 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class AddressingOutHandlerTest method testAxis2IncludeOptionalHeadersFalse.

public void testAxis2IncludeOptionalHeadersFalse() throws Exception {
    File configFile = new File(System.getProperty("basedir", ".") + "/test-resources/axis2-IncludeOptionalHeadersFalse.xml");
    ConfigurationContext cfgCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-classes", configFile.getAbsolutePath());
    msgCtxt = cfgCtx.createMessageContext();
    msgCtxt.setEnvelope(OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope());
    msgCtxt.setTo(new EndpointReference("http://www.to.org/service/"));
    msgCtxt.setFrom(new EndpointReference("http://www.from.org/service/"));
    msgCtxt.setReplyTo(new EndpointReference("http://www.replyTo.org/service/"));
    msgCtxt.setFaultTo(new EndpointReference("http://www.faultTo.org/service/"));
    msgCtxt.setWSAAction("http://www.actions.org/action");
    msgCtxt.setMessageID("123456-7890");
    msgCtxt.addRelatesTo(new RelatesTo("http://www.relatesTo.org/service/"));
    msgCtxt.setProperty(WS_ADDRESSING_VERSION, Final.WSA_NAMESPACE);
    outHandler.invoke(msgCtxt);
    XMLUnit.setIgnoreWhitespace(true);
    assertXMLEqual(msgCtxt.getEnvelope().toString(), TestUtil.getOMBuilder("addressingEnabledTest.xml").getDocumentElement().toString());
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) File(java.io.File) RelatesTo(org.apache.axis2.addressing.RelatesTo) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 72 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class AddressingOutHandlerTest method testMustUnderstandSupport.

public void testMustUnderstandSupport() throws Exception {
    ConfigurationContext cfgCtx = ConfigurationContextFactory.createEmptyConfigurationContext();
    msgCtxt = cfgCtx.createMessageContext();
    msgCtxt.setProperty(AddressingConstants.ADD_MUST_UNDERSTAND_TO_ADDRESSING_HEADERS, Boolean.TRUE);
    EndpointReference epr = new EndpointReference("http://www.from.org/service/");
    epr.addReferenceParameter(new QName("Reference2"), "Value 200");
    msgCtxt.setFrom(epr);
    epr = new EndpointReference("http://www.to.org/service/");
    epr.addReferenceParameter(new QName("http://reference.org", "Reference4", "myRef"), "Value 400");
    epr.addReferenceParameter(new QName("http://reference.org", "Reference3", "myRef"), "Value 300");
    msgCtxt.setTo(epr);
    msgCtxt.setProperty(WS_ADDRESSING_VERSION, Submission.WSA_NAMESPACE);
    epr = new EndpointReference("http://www.replyTo.org/service/");
    msgCtxt.setReplyTo(epr);
    msgCtxt.setMessageID("123456-7890");
    msgCtxt.setWSAAction("http://www.actions.org/action");
    org.apache.axis2.addressing.RelatesTo relatesTo = new org.apache.axis2.addressing.RelatesTo("http://www.relatesTo.org/service/", "TestRelation");
    msgCtxt.addRelatesTo(relatesTo);
    msgCtxt.setEnvelope(OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope());
    outHandler.invoke(msgCtxt);
    XMLUnit.setIgnoreWhitespace(true);
    assertXMLEqual(TestUtil.getOMBuilder("mustUnderstandTest.xml").getDocumentElement().toString(), msgCtxt.getEnvelope().toString());
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) QName(javax.xml.namespace.QName) RelatesTo(org.apache.axis2.addressing.RelatesTo) RelatesTo(org.apache.axis2.addressing.RelatesTo) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 73 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class AddressingOutHandlerTest method testDuplicateHeadersWithOverridingOn.

public void testDuplicateHeadersWithOverridingOn() throws Exception {
    // this will check whether we can add to epr, if there is one already.
    EndpointReference eprOne = new EndpointReference("http://whatever.org");
    RelatesTo custom = new RelatesTo("urn:id", "customRelationship");
    ConfigurationContext cfgCtx = ConfigurationContextFactory.createEmptyConfigurationContext();
    msgCtxt = cfgCtx.createMessageContext();
    SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
    SOAPEnvelope defaultEnvelope = factory.getDefaultEnvelope();
    OMNamespace addressingNamespace = factory.createOMNamespace(Final.WSA_NAMESPACE, WSA_DEFAULT_PREFIX);
    SOAPHeaderBlock soapHeaderBlock = defaultEnvelope.getHeader().addHeaderBlock(WSA_TO, addressingNamespace);
    soapHeaderBlock.setText("http://oldEPR.org");
    soapHeaderBlock = defaultEnvelope.getHeader().addHeaderBlock(WSA_RELATES_TO, addressingNamespace);
    soapHeaderBlock.setText("urn:id");
    soapHeaderBlock = defaultEnvelope.getHeader().addHeaderBlock(WSA_RELATES_TO, addressingNamespace);
    soapHeaderBlock.setText("urn:id");
    soapHeaderBlock.addAttribute(WSA_RELATES_TO_RELATIONSHIP_TYPE, custom.getRelationshipType(), null);
    msgCtxt.setEnvelope(defaultEnvelope);
    msgCtxt.setProperty(REPLACE_ADDRESSING_HEADERS, Boolean.TRUE);
    msgCtxt.addRelatesTo(custom);
    msgCtxt.setTo(eprOne);
    msgCtxt.setWSAAction("http://www.actions.org/action");
    outHandler.invoke(msgCtxt);
    assertEquals("http://whatever.org", defaultEnvelope.getHeader().getFirstChildWithName(Final.QNAME_WSA_TO).getText());
    Iterator<OMElement> iterator = defaultEnvelope.getHeader().getChildrenWithName(Final.QNAME_WSA_RELATES_TO);
    int i = 0;
    while (iterator.hasNext()) {
        iterator.next();
        i++;
    }
    assertEquals("Custom should replace reply.", 1, i);
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) OMNamespace(org.apache.axiom.om.OMNamespace) SOAPHeaderBlock(org.apache.axiom.soap.SOAPHeaderBlock) OMElement(org.apache.axiom.om.OMElement) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) RelatesTo(org.apache.axis2.addressing.RelatesTo) SOAPFactory(org.apache.axiom.soap.SOAPFactory) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 74 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class AddressingOutHandlerTest method testModuleDisableAddressingForOutMessagesFalse.

public void testModuleDisableAddressingForOutMessagesFalse() throws Exception {
    File configFile = new File(System.getProperty("basedir", ".") + "/test-resources/axis2-noParameters.xml");
    ConfigurationContext cfgCtx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("target/test-classes", configFile.getAbsolutePath());
    AxisConfiguration config = cfgCtx.getAxisConfiguration();
    // Can't test with a module.xml file in test-resources because it gets
    // overridden by target\classes\META-INF\module.xml, so create our own
    // AxisModule with the required parameter value
    AxisModule module = config.getModule("addressing");
    module.addParameter(new Parameter("disableAddressingForOutMessages", "false"));
    msgCtxt = cfgCtx.createMessageContext();
    msgCtxt.setEnvelope(OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope());
    msgCtxt.setTo(new EndpointReference("http://www.to.org/service/"));
    msgCtxt.setFrom(new EndpointReference("http://www.from.org/service/"));
    msgCtxt.setReplyTo(new EndpointReference("http://www.replyTo.org/service/"));
    msgCtxt.setFaultTo(new EndpointReference("http://www.faultTo.org/service/"));
    msgCtxt.setWSAAction("http://www.actions.org/action");
    msgCtxt.setMessageID("123456-7890");
    msgCtxt.addRelatesTo(new RelatesTo("http://www.relatesTo.org/service/"));
    msgCtxt.setProperty(WS_ADDRESSING_VERSION, Final.WSA_NAMESPACE);
    outHandler.invoke(msgCtxt);
    XMLUnit.setIgnoreWhitespace(true);
    assertXMLEqual(msgCtxt.getEnvelope().toString(), TestUtil.getOMBuilder("addressingEnabledTest.xml").getDocumentElement().toString());
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) Parameter(org.apache.axis2.description.Parameter) File(java.io.File) RelatesTo(org.apache.axis2.addressing.RelatesTo) AxisModule(org.apache.axis2.description.AxisModule) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Example 75 with EndpointReference

use of org.apache.axis2.addressing.EndpointReference in project axis-axis2-java-core by apache.

the class AddressingOutHandlerTest method testHeaderCreationFromMsgCtxtInformation.

public void testHeaderCreationFromMsgCtxtInformation() throws Exception {
    ConfigurationContext cfgCtx = ConfigurationContextFactory.createEmptyConfigurationContext();
    msgCtxt = cfgCtx.createMessageContext();
    EndpointReference epr = new EndpointReference("http://www.from.org/service/");
    epr.addReferenceParameter(new QName("Reference2"), "Value 200");
    msgCtxt.setFrom(epr);
    epr = new EndpointReference("http://www.to.org/service/");
    epr.addReferenceParameter(new QName("http://reference.org", "Reference4", "myRef"), "Value 400");
    epr.addReferenceParameter(new QName("http://reference.org", "Reference3", "myRef"), "Value 300");
    msgCtxt.setTo(epr);
    msgCtxt.setProperty(WS_ADDRESSING_VERSION, Submission.WSA_NAMESPACE);
    epr = new EndpointReference("http://www.replyTo.org/service/");
    msgCtxt.setReplyTo(epr);
    msgCtxt.setMessageID("123456-7890");
    msgCtxt.setWSAAction("http://www.actions.org/action");
    org.apache.axis2.addressing.RelatesTo relatesTo = new org.apache.axis2.addressing.RelatesTo("http://www.relatesTo.org/service/", "TestRelation");
    msgCtxt.addRelatesTo(relatesTo);
    msgCtxt.setEnvelope(OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope());
    outHandler.invoke(msgCtxt);
    XMLUnit.setIgnoreWhitespace(true);
    assertXMLEqual(msgCtxt.getEnvelope().toString(), TestUtil.getOMBuilder("OutHandlerTest.xml").getDocumentElement().toString());
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) QName(javax.xml.namespace.QName) RelatesTo(org.apache.axis2.addressing.RelatesTo) RelatesTo(org.apache.axis2.addressing.RelatesTo) EndpointReference(org.apache.axis2.addressing.EndpointReference)

Aggregations

EndpointReference (org.apache.axis2.addressing.EndpointReference)261 Options (org.apache.axis2.client.Options)99 OMElement (org.apache.axiom.om.OMElement)67 AxisFault (org.apache.axis2.AxisFault)66 MessageContext (org.apache.axis2.context.MessageContext)58 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)57 ServiceClient (org.apache.axis2.client.ServiceClient)54 QName (javax.xml.namespace.QName)40 ArrayList (java.util.ArrayList)37 AxisService (org.apache.axis2.description.AxisService)28 Map (java.util.Map)25 MessageContext (org.apache.synapse.MessageContext)25 Axis2MessageContext (org.apache.synapse.core.axis2.Axis2MessageContext)25 Test (org.junit.Test)20 IOException (java.io.IOException)19 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)18 RelatesTo (org.apache.axis2.addressing.RelatesTo)18 URL (java.net.URL)17 SOAPFactory (org.apache.axiom.soap.SOAPFactory)17 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)17