本文整理汇总了Java中org.apache.axis2.context.ConfigurationContextFactory.createEmptyConfigurationContext方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationContextFactory.createEmptyConfigurationContext方法的具体用法?Java ConfigurationContextFactory.createEmptyConfigurationContext怎么用?Java ConfigurationContextFactory.createEmptyConfigurationContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.ConfigurationContextFactory
的用法示例。
在下文中一共展示了ConfigurationContextFactory.createEmptyConfigurationContext方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testFindService
import org.apache.axis2.context.ConfigurationContextFactory; //导入方法依赖的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: extractAddressingInformationFromHeaders
import org.apache.axis2.context.ConfigurationContextFactory; //导入方法依赖的package包/类
protected Options extractAddressingInformationFromHeaders(RolePlayer rolePlayer)
throws Exception {
String testfile = "valid-messages/" + versionDirectory + "/" + testFileName;
MessageContext mc = new MessageContext();
final ConfigurationContext context =
ConfigurationContextFactory.createEmptyConfigurationContext();
mc.setConfigurationContext(context);
if (rolePlayer != null) {
mc.getConfigurationContext().getAxisConfiguration()
.addParameter(Constants.SOAP_ROLE_PLAYER_PARAMETER, rolePlayer);
}
basicExtractAddressingInformationFromHeaders(testfile, mc);
Options options = mc.getOptions();
if (options == null) {
fail("Addressing Information Headers have not been retrieved properly");
}
assertEquals("action header is not correct", action, options.getAction());
assertActionHasExtensibilityAttribute(mc);
assertEquals("message id header is not correct",
options.getMessageId().trim(),
messageID.trim());
assertMessageIDHasExtensibilityAttribute(mc);
assertFullFromEPR(options.getFrom());
assertFullFaultEPR(options.getFaultTo());
assertFullReplyToEPR(options.getReplyTo());
assertRelationships(options);
return options;
}
示例3: testMessageWithOmittedHeaders
import org.apache.axis2.context.ConfigurationContextFactory; //导入方法依赖的package包/类
protected Options testMessageWithOmittedHeaders(String testName) throws Exception {
String testfile =
"omitted-header-messages/" + versionDirectory + "/" + testName + "Message.xml";
MessageContext mc = new MessageContext();
ConfigurationContext cc = ConfigurationContextFactory.createEmptyConfigurationContext();
mc.setConfigurationContext(cc);
basicExtractAddressingInformationFromHeaders(testfile, mc);
return mc.getOptions();
}
示例4: testDuplicateHeaders
import org.apache.axis2.context.ConfigurationContextFactory; //导入方法依赖的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);
}
示例5: testDuplicateHeadersWithOverridingOff
import org.apache.axis2.context.ConfigurationContextFactory; //导入方法依赖的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);
}
示例6: testFindOperation
import org.apache.axis2.context.ConfigurationContextFactory; //导入方法依赖的package包/类
public void testFindOperation() throws AxisFault {
MessageContext messageContext;
AxisService as1 = new AxisService("Service1");
AxisOperation operation1 = new InOnlyAxisOperation(new QName("operation1"));
AxisOperation operation2 = new InOnlyAxisOperation(new QName("operation2"));
as1.addOperation(operation1);
as1.addOperation(operation2);
ConfigurationContext cc = ConfigurationContextFactory.createEmptyConfigurationContext();
AxisConfiguration ac = cc.getAxisConfiguration();
ac.addService(as1);
messageContext = cc.createMessageContext();
messageContext.setAxisService(as1);
SOAPEnvelope se = OMAbstractFactory.getSOAP11Factory().createSOAPEnvelope();
SOAPBody sb = OMAbstractFactory.getSOAP11Factory().createSOAPBody(se);
sb.addChild(OMAbstractFactory.getSOAP11Factory().createOMElement("operation2",
"http://test", "pfx"));
messageContext.setEnvelope(se);
SOAPMessageBodyBasedOperationDispatcher ruisd =
new SOAPMessageBodyBasedOperationDispatcher();
ruisd.invoke(messageContext);
assertEquals(operation2, messageContext.getAxisOperation());
}
示例7: testParameterEdit
import org.apache.axis2.context.ConfigurationContextFactory; //导入方法依赖的package包/类
public void testParameterEdit() throws Exception{
ConfigurationContext configCtx = ConfigurationContextFactory.createEmptyConfigurationContext();
AxisConfiguration axisConfig = configCtx.getAxisConfiguration();
Parameter parameter = new Parameter();
parameter.setValue("true");
parameter.setName("enableMTOM");
axisConfig.addParameter(parameter);
parameter.setValue("true");
AxisServiceGroup serviceGroup = new AxisServiceGroup();
serviceGroup.setServiceGroupName("testServiceGroup");
AxisService service = new AxisService();
service.setName("service");
serviceGroup.addService(service);
axisConfig.addServiceGroup(serviceGroup);
parameter = serviceGroup.getParameter("enableMTOM");
parameter.setValue("true");
Parameter para2= serviceGroup.getParameter("enableMTOM");
assertEquals(para2.getValue(),"true");
Parameter test = new Parameter();
test.setName("test");
test.setValue("test");
serviceGroup.addParameter(test);
Parameter para = serviceGroup.getParameter("test");
assertNotNull(para);
assertEquals(para.getValue(),"test");
para.setValue("newValue");
para = serviceGroup.getParameter("test");
assertNotNull(para);
assertEquals(para.getValue(),"newValue");
}
示例8: setUp
import org.apache.axis2.context.ConfigurationContextFactory; //导入方法依赖的package包/类
protected void setUp() throws Exception {
configContext =
ConfigurationContextFactory.createEmptyConfigurationContext();
lm = new ListenerManager();
lm.init(configContext);
lm.start();
}
示例9: testAddToSOAPHeader
import org.apache.axis2.context.ConfigurationContextFactory; //导入方法依赖的package包/类
public void testAddToSOAPHeader() throws Exception {
EndpointReference replyTo = new EndpointReference(
"http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous");
EndpointReference epr = new EndpointReference("http://www.to.org/service/");
for (int i = 0; i < 5; i++) {
epr.addReferenceParameter(
new QName(Submission.WSA_NAMESPACE, "Reference" + i,
AddressingConstants.WSA_DEFAULT_PREFIX),
"Value " + i * 100);
}
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope defaultEnvelope = factory.getDefaultEnvelope();
ConfigurationContext configCtx =
ConfigurationContextFactory.createEmptyConfigurationContext();
MessageContext msgCtxt = configCtx.createMessageContext();
msgCtxt.setProperty(WS_ADDRESSING_VERSION, Submission.WSA_NAMESPACE);
msgCtxt.setTo(epr);
msgCtxt.setReplyTo(replyTo);
msgCtxt.setEnvelope(defaultEnvelope);
msgCtxt.setWSAAction("http://www.actions.org/action");
msgCtxt.setMessageID("urn:test:123");
OMAttribute extAttr = OMAbstractFactory.getOMFactory().createOMAttribute("AttrExt",
OMAbstractFactory
.getOMFactory().createOMNamespace(
"http://ws.apache.org/namespaces/axis2",
"axis2"),
"123456789");
ArrayList al = new ArrayList();
al.add(extAttr);
msgCtxt.setProperty(AddressingConstants.ACTION_ATTRIBUTES, al);
msgCtxt.setProperty(AddressingConstants.MESSAGEID_ATTRIBUTES, al);
outHandler.invoke(msgCtxt);
OMXMLParserWrapper omBuilder = TestUtil.getOMBuilder("eprTest.xml");
XMLUnit.setIgnoreWhitespace(true);
assertXMLEqual(omBuilder.getDocumentElement().toString(), defaultEnvelope.toString());
}
示例10: testDuplicateHeadersWithOverridingOn
import org.apache.axis2.context.ConfigurationContextFactory; //导入方法依赖的package包/类
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 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);
}
示例11: createMessageContext
import org.apache.axis2.context.ConfigurationContextFactory; //导入方法依赖的package包/类
private MessageContext createMessageContext(SOAPFactory soapFactory) {
MessageContext messageContext = null;
AxisService as1 = new AxisService("Service1");
ConfigurationContext cc = null;
try {
cc = ConfigurationContextFactory.createEmptyConfigurationContext();
AxisConfiguration ac = cc.getAxisConfiguration();
ac.addService(as1);
messageContext = cc.createMessageContext();
messageContext.setAxisService(as1);
SOAPEnvelope se = soapFactory.createSOAPEnvelope();
SOAPHeader sh = soapFactory.createSOAPHeader(se);
SOAPHeaderBlock shb1 = sh.addHeaderBlock(header_ultimateReceiver,
omFactory.createOMNamespace(namespace, header_ultimateReceiver));
// Since no role was set on the shb1, default is ultimate receiver
shb1.setMustUnderstand(true);
SOAPHeaderBlock shb2 = sh.addHeaderBlock(header_rolePlayed,
omFactory.createOMNamespace(namespace, header_rolePlayed));
shb2.setRole(rolePlayed1);
shb2.setMustUnderstand(true);
SOAPHeaderBlock shb3 = sh.addHeaderBlock(header_roleNotPlayed,
omFactory.createOMNamespace(namespace, header_roleNotPlayed));
shb3.setRole(roleNotPlayed);
shb3.setMustUnderstand(true);
SOAPHeaderBlock shb4 = sh.addHeaderBlock(header_bindingAdded,
omFactory.createOMNamespace(namespace, header_bindingAdded));
shb4.setRole(roleBindingAdded);
shb4.setMustUnderstand(true);
// This header is destined for the ulmiate receiver, but it is already processed
// so it shouldn't cause mustUnderstand fault
SOAPHeaderBlock shb5 = sh.addHeaderBlock(header_ultimateReceiver_processed,
omFactory.createOMNamespace(namespace, header_ultimateReceiver_processed));
// Since no role was set on the shb1, default is ultimate receiver
shb5.setMustUnderstand(true);
shb5.setProcessed();
// Header targeted for SOAP11 role of Next, not set to MustUnderstand
SOAPHeaderBlock shb6 = sh.addHeaderBlock(header_SoapNext,
omFactory.createOMNamespace(soap11Namespace, header_SoapNext));
shb6.setRole(roleSoap11Next);
messageContext.setEnvelope(se);
} catch (AxisFault e) {
fail("Caught unexpected exception creating message context" + e);
}
return messageContext;
}
示例12: testFindService
import org.apache.axis2.context.ConfigurationContextFactory; //导入方法依赖的package包/类
public void testFindService() throws AxisFault {
MessageContext messageContext;
//Global services
AxisService as1 = new AxisService("Service1");
as1.addEndpoint("Service1Endpoint", new AxisEndpoint());
//Hierarchical Services
AxisService as2 = new AxisService("foo/bar/Version");
AxisService as3 = new AxisService("foo/bar/1.0.1/Echo");
as2.addEndpoint("VersionEndpoint", new AxisEndpoint());
as3.addEndpoint("EchoEndpoint", new AxisEndpoint());
AxisOperation operation1 = new InOnlyAxisOperation(new QName("operation1"));
AxisOperation operation2 = new InOnlyAxisOperation(new QName("operation2"));
as1.addOperation(operation1);
as1.addOperation(operation2);
AxisOperation operation3 = new InOnlyAxisOperation(new QName("getVersion"));
AxisOperation operation4 = new InOnlyAxisOperation(new QName("echo"));
as2.addOperation(operation3);
as3.addOperation(operation4);
ConfigurationContext cc = ConfigurationContextFactory.createEmptyConfigurationContext();
AxisConfiguration ac = cc.getAxisConfiguration();
ac.addService(as1);
ac.addService(as2);
ac.addService(as3);
RequestURIBasedOperationDispatcher ruisd = new RequestURIBasedOperationDispatcher();
/**
* Tests for global services
*/
messageContext = cc.createMessageContext();
messageContext.setTo(new EndpointReference("http://127.0.0.1:8080" +
"/axis2/services/Service1/operation2"));
messageContext.setAxisService(as1);
ruisd.invoke(messageContext);
assertEquals(operation2, messageContext.getAxisOperation());
messageContext = cc.createMessageContext();
messageContext.setTo(new EndpointReference("http://127.0.0.1:8080" +
"/axis2/services/Service1.Service1Endpoint/operation2"));
messageContext.setAxisService(as1);
ruisd.invoke(messageContext);
assertEquals(operation2, messageContext.getAxisOperation());
/**
* Tests for hierarchical services
*/
messageContext = cc.createMessageContext();
messageContext.setTo(new EndpointReference("http://127.0.0.1:8080" +
"/axis2/services/foo/bar/Version/getVersion"));
messageContext.setAxisService(as2);
ruisd.invoke(messageContext);
assertEquals(operation3, messageContext.getAxisOperation());
messageContext = cc.createMessageContext();
messageContext.setTo(new EndpointReference("http://127.0.0.1:8080" +
"/axis2/services/foo/bar/Version.VersionEndpoint/getVersion"));
messageContext.setAxisService(as2);
ruisd.invoke(messageContext);
assertEquals(operation3, messageContext.getAxisOperation());
messageContext = cc.createMessageContext();
messageContext.setTo(new EndpointReference("http://127.0.0.1:8080" +
"/axis2/services/foo/bar/1.0.1/Echo/echo"));
messageContext.setAxisService(as3);
ruisd.invoke(messageContext);
assertEquals(operation4, messageContext.getAxisOperation());
messageContext = cc.createMessageContext();
messageContext.setTo(new EndpointReference("http://127.0.0.1:8080" +
"/axis2/services/foo/bar/1.0.1/Echo.EchoEndpoint/echo"));
messageContext.setAxisService(as3);
ruisd.invoke(messageContext);
assertEquals(operation4, messageContext.getAxisOperation());
}