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());
}
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());
}
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);
}
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());
}
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());
}
Aggregations