本文整理汇总了Java中org.apache.axis2.context.ConfigurationContext.createMessageContext方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationContext.createMessageContext方法的具体用法?Java ConfigurationContext.createMessageContext怎么用?Java ConfigurationContext.createMessageContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.ConfigurationContext
的用法示例。
在下文中一共展示了ConfigurationContext.createMessageContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFindService
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testFindService() throws AxisFault {
MessageContext messageContext;
AxisService as1 = new AxisService("Service1");
AxisService as2 = new AxisService("Service2");
ConfigurationContext cc = ConfigurationContextFactory.createEmptyConfigurationContext();
AxisConfiguration ac = cc.getAxisConfiguration();
ac.addService(as1);
ac.addService(as2);
messageContext = cc.createMessageContext();
SOAPEnvelope se = OMAbstractFactory.getSOAP11Factory().createSOAPEnvelope();
SOAPBody sb = OMAbstractFactory.getSOAP11Factory().createSOAPBody(se);
sb.addChild(OMAbstractFactory.getSOAP11Factory().createOMElement("operation2",
"http://127.0.0.1:8080/axis2/services/Service2",
"pfx"));
messageContext.setEnvelope(se);
SOAPMessageBodyBasedServiceDispatcher ruisd = new SOAPMessageBodyBasedServiceDispatcher();
ruisd.invoke(messageContext);
assertEquals(as2, messageContext.getAxisService());
}
示例2: testFaultReason
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testFaultReason() throws Exception {
SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
OMElement response = soapFactory.createOMElement(new QName("testNs",
"test"));
String faultReason = "myFaultReason";
AxisFault fault = new AxisFault(new QName("myQname"), faultReason,
"myFaultNode", "myFaultRole", response);
ConfigurationContext cc = ConfigurationContextFactory
.createDefaultConfigurationContext();
MessageContext ctx = cc.createMessageContext();
SOAPFactory fac = OMAbstractFactory.getSOAP12Factory();
ctx.setEnvelope(fac.getDefaultEnvelope());
MessageContext faultCtx = MessageContextBuilder
.createFaultMessageContext(ctx, fault);
assertEquals(faultReason, Utils.getInboundFaultFromMessageContext(
faultCtx).getReason());
}
示例3: testMesssageContext
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testMesssageContext() throws AxisFault,
SOAPProcessingException {
AxisConfiguration er = new AxisConfiguration();
AxisService servicesDesc = new AxisService();
servicesDesc.setName("testService");
er.addService(servicesDesc);
ConfigurationContext engineContext = new ConfigurationContext(er);
MessageContext msgctx = engineContext.createMessageContext();
SOAPFactory omFac = OMAbstractFactory.getSOAP11Factory();
msgctx.setEnvelope(omFac.getDefaultEnvelope());
assertNotNull(msgctx.getEnvelope());
msgctx.setFaultTo(null);
assertNull(msgctx.getFaultTo());
msgctx.setFrom(null);
assertNull(msgctx.getFrom());
msgctx.setReplyTo(null);
assertNull(msgctx.getReplyTo());
}
示例4: testFindOperation
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testFindOperation() throws Exception {
ConfigurationContext cc = new ConfigurationContext(new AxisConfiguration());
MessageContext messageContext = cc.createMessageContext();
AxisService as = new AxisService("Service1");
messageContext.setAxisService(as);
AxisOperation operation1 = new InOnlyAxisOperation(new QName("operation1"));
operation1.setSoapAction("urn:org.apache.axis2.dispatchers.test:operation1");
AxisOperation operation2 = new InOnlyAxisOperation(new QName("operation2"));
operation2.setSoapAction("urn:org.apache.axis2.dispatchers.test:operation2");
as.addOperation(operation1);
as.addOperation(operation2);
messageContext.setSoapAction("urn:org.apache.axis2.dispatchers.test:operation1");
SOAPActionBasedDispatcher soapActionDispatcher = new SOAPActionBasedDispatcher();
soapActionDispatcher.invoke(messageContext);
assertEquals(operation1, messageContext.getAxisOperation());
}
示例5: testAxis2DisableAddressingForOutMessagesFalse
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testAxis2DisableAddressingForOutMessagesFalse() throws Exception {
File configFile = new File(System.getProperty("basedir",".") +
"/test-resources/axis2-disableAddressingForOutMessagesFalse.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());
}
示例6: testAxis2IncludeOptionalHeadersTrue
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testAxis2IncludeOptionalHeadersTrue() throws Exception {
File configFile = new File(System.getProperty("basedir",".") +
"/test-resources/axis2-IncludeOptionalHeadersTrue.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("withOptionalHeadersTest.xml")
.getDocumentElement().toString());
}
示例7: testAxis2IncludeOptionalHeadersFalse
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
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());
}
示例8: testFaultSerialization
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testFaultSerialization() throws Exception {
final String REASON = "ReasonValue";
SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory();
SOAPFaultCode soapFaultCode = soapFactory.createSOAPFaultCode();
SOAPFaultValue soapFaultValue = soapFactory
.createSOAPFaultValue(soapFaultCode);
soapFaultValue.setText(new QName(
SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI, "Sender"));
SOAPFaultReason soapFaultReason = soapFactory.createSOAPFaultReason();
SOAPFaultText soapFaultText = soapFactory
.createSOAPFaultText(soapFaultReason);
soapFaultText.setText(REASON);
SOAPFaultDetail soapFaultDetail = soapFactory.createSOAPFaultDetail();
QName qName = new QName("http://mycompany.com", "FaultException", "ex");
OMElement exception = soapFactory.createOMElement(qName,
soapFaultDetail);
exception.setText("Detail text");
AxisFault fault = new AxisFault(soapFaultCode, soapFaultReason, null,
null, soapFaultDetail);
ConfigurationContext cc = ConfigurationContextFactory
.createDefaultConfigurationContext();
MessageContext ctx = cc.createMessageContext();
SOAPFactory fac = OMAbstractFactory.getSOAP12Factory();
ctx.setEnvelope(fac.getDefaultEnvelope());
MessageContext faultCtx = MessageContextBuilder
.createFaultMessageContext(ctx, fault);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
TransportUtils.writeMessage(faultCtx, bos);
String result = new String(bos.toByteArray());
// For right now, just making sure we have a test for AXIS2-2752
// Confirm reason was correctly processed
assertTrue("Incorrect or missing reason!", result.indexOf(REASON) > -1);
}
示例9: createMessageContext
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
private MessageContext createMessageContext(OperationContext oc, ConfigurationContext cc,
int flowType) throws Exception {
MessageContext mc = cc.createMessageContext();
mc.setFLOW(flowType);
mc.setTransportIn(transportIn);
mc.setTransportOut(transportOut);
mc.setServerSide(true);
// mc.setProperty(MessageContext.TRANSPORT_OUT, System.out);
SOAPFactory omFac = OMAbstractFactory.getSOAP11Factory();
mc.setEnvelope(omFac.getDefaultEnvelope());
AxisOperation axisOperation = oc.getAxisOperation();
String action = axisOperation.getName().getLocalPart();
mc.setSoapAction(action);
// System.out.flush();
mc.setMessageID(UUIDGenerator.getUUID());
axisOperation.registerOperationContext(mc, oc);
mc.setOperationContext(oc);
ServiceContext sc = oc.getServiceContext();
mc.setServiceContext(sc);
mc.setTo(new EndpointReference("axis2/services/NullService"));
mc.setWSAAction("DummyOp");
AxisMessage axisMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
mc.setAxisMessage(axisMessage);
return mc;
}
示例10: testFindOperation
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testFindOperation() throws AxisFault {
MessageContext messageContext;
AxisService as1 = new AxisService("Service1");
AxisConfiguration ac = new AxisConfiguration();
ac.addService(as1);
AxisOperation operation1 = new InOnlyAxisOperation(new QName("operation1"));
AxisOperation operation2 = new InOnlyAxisOperation(new QName("operation2"));
as1.addOperation(operation1);
as1.addOperation(operation2);
ConfigurationContext cc = new ConfigurationContext(ac);
ServiceGroupContext sgc = cc.createServiceGroupContext(as1.getAxisServiceGroup());
ServiceContext serviceContext = sgc.getServiceContext(as1);
OperationContext oc1 = serviceContext.createOperationContext(operation1);
OperationContext oc2 = serviceContext.createOperationContext(operation2);
cc.registerOperationContext("urn:org.apache.axis2.dispatchers.messageid:123", oc1);
cc.registerOperationContext("urn:org.apache.axis2.dispatchers.messageid:456", oc2);
messageContext = cc.createMessageContext();
messageContext
.addRelatesTo(new RelatesTo("urn:org.apache.axis2.dispatchers.messageid:456"));
messageContext.setAxisService(as1);
RelatesToBasedOperationDispatcher ruisd = new RelatesToBasedOperationDispatcher();
ruisd.invoke(messageContext);
assertEquals(operation2, messageContext.getAxisOperation());
}
示例11: testDuplicateHeaders
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testDuplicateHeaders() throws Exception {
// this will check whether we can add to epr, if there is one already.
EndpointReference eprOne = new EndpointReference("http://whatever.org");
EndpointReference duplicateEpr = new EndpointReference("http://whatever.duplicate.org");
RelatesTo reply = new RelatesTo("urn:id");
ConfigurationContext cfgCtx =
ConfigurationContextFactory.createEmptyConfigurationContext();
msgCtxt = cfgCtx.createMessageContext();
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope defaultEnvelope = factory.getDefaultEnvelope();
msgCtxt.setEnvelope(defaultEnvelope);
msgCtxt.addRelatesTo(reply);
msgCtxt.setTo(eprOne);
msgCtxt.setWSAAction("http://www.actions.org/action");
outHandler.invoke(msgCtxt);
// now the soap message within the msgCtxt must have a to header.
// lets invoke twice and see
msgCtxt.setTo(duplicateEpr);
outHandler.invoke(msgCtxt);
assertEquals("http://whatever.org", defaultEnvelope.getHeader()
.getFirstChildWithName(Final.QNAME_WSA_TO).getText());
Iterator iterator =
defaultEnvelope.getHeader().getChildrenWithName(Final.QNAME_WSA_RELATES_TO);
int i = 0;
while (iterator.hasNext()) {
iterator.next();
i++;
}
assertEquals("Reply should be added twice.", 2, i);
}
示例12: testDuplicateHeadersWithOverridingOff
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testDuplicateHeadersWithOverridingOff() 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");
msgCtxt.setEnvelope(defaultEnvelope);
msgCtxt.setProperty(REPLACE_ADDRESSING_HEADERS, Boolean.FALSE);
msgCtxt.addRelatesTo(custom);
msgCtxt.setTo(eprOne);
msgCtxt.setWSAAction("http://www.actions.org/action");
outHandler.invoke(msgCtxt);
assertEquals("http://oldEPR.org", defaultEnvelope.getHeader()
.getFirstChildWithName(Final.QNAME_WSA_TO).getText());
Iterator iterator =
defaultEnvelope.getHeader().getChildrenWithName(Final.QNAME_WSA_RELATES_TO);
int i = 0;
while (iterator.hasNext()) {
iterator.next();
i++;
}
assertEquals("Both reply and custom should be found.", 2, i);
}
示例13: testModuleDisableAddressingForOutMessagesTrue
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testModuleDisableAddressingForOutMessagesTrue() 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", "true"));
msgCtxt = cfgCtx.createMessageContext();
// Need to add a SOAP Header to stop this error from XMLComparator:
// "There is no Header element under Envelope"
SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
SOAPHeaderBlock soapHeaderBlock = envelope.getHeader().addHeaderBlock(
"testHeader", new OMNamespaceImpl("http://test.com", "test"));
msgCtxt.setEnvelope(envelope);
outHandler.invoke(msgCtxt);
XMLUnit.setIgnoreWhitespace(true);
assertXMLEqual(msgCtxt.getEnvelope().toString(), TestUtil
.getOMBuilder("addressingDisabledTest.xml")
.getDocumentElement().toString());
}
示例14: testFindService
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testFindService() throws AxisFault {
MessageContext messageContext;
AxisConfiguration ac = new AxisConfiguration();
ConfigurationContext cc = new ConfigurationContext(ac);
AxisService as1 = new AxisService("Service1");
AxisServiceGroup sg = new AxisServiceGroup(ac);
sg.addService(as1);
ServiceGroupContext sgc = cc.createServiceGroupContext(sg);
ServiceContext sc1 = sgc.getServiceContext(as1);
AxisService as2 = new AxisService("Service2");
sg.addService(as2);
ServiceContext sc2 = sgc.getServiceContext(as2);
ac.addService(as1);
ac.addService(as2);
AxisOperation operation1 = new InOnlyAxisOperation(new QName("operation1"));
AxisOperation operation2 = new InOnlyAxisOperation(new QName("operation2"));
as1.addOperation(operation1);
as2.addOperation(operation2);
OperationContext oc1 = sc1.createOperationContext(operation1);
OperationContext oc2 = sc2.createOperationContext(operation2);
cc.registerOperationContext("urn:org.apache.axis2.dispatchers.messageid:123", oc1);
cc.registerOperationContext("urn:org.apache.axis2.dispatchers.messageid:456", oc2);
messageContext = cc.createMessageContext();
messageContext
.addRelatesTo(new RelatesTo("urn:org.apache.axis2.dispatchers.messageid:456"));
RelatesToBasedServiceDispatcher ruisd = new RelatesToBasedServiceDispatcher();
ruisd.invoke(messageContext);
assertEquals(as2, messageContext.getAxisService());
}
示例15: testModuleIncludeOptionalHeadersTrue
import org.apache.axis2.context.ConfigurationContext; //导入方法依赖的package包/类
public void testModuleIncludeOptionalHeadersTrue() 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("includeOptionalHeaders", "true"));
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("withOptionalHeadersTest.xml")
.getDocumentElement().toString());
}