本文整理汇总了Java中org.apache.axis2.context.MessageContext.setConfigurationContext方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.setConfigurationContext方法的具体用法?Java MessageContext.setConfigurationContext怎么用?Java MessageContext.setConfigurationContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.setConfigurationContext方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static MessageContext createMessageContext(OMElement payload,
OMElement topic,
int tenantId) throws EventBrokerException {
MessageContext mc = new MessageContext();
mc.setConfigurationContext(new ConfigurationContext(new AxisConfiguration()));
PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(tenantId);
SOAPFactory soapFactory = new SOAP12Factory();
SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
envelope.getBody().addChild(payload);
if (topic != null) {
envelope.getHeader().addChild(topic);
}
try {
mc.setEnvelope(envelope);
} catch (Exception e) {
throw new EventBrokerException("Unable to generate event.", e);
}
return mc;
}
示例2: createMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Create a new axis MessageContext for an incoming message through this transport
* @return the newly created message context
*/
public MessageContext createMessageContext() {
MessageContext msgCtx = new MessageContext();
msgCtx.setConfigurationContext(cfgCtx);
msgCtx.setIncomingTransportName(getTransportName());
msgCtx.setTransportOut(transportOut);
msgCtx.setTransportIn(transportIn);
msgCtx.setServerSide(true);
msgCtx.setMessageID(UUIDGenerator.getUUID());
// There is a discrepency in what I thought, Axis2 spawns a nes threads to
// send a message is this is TRUE - and I want it to be the other way
msgCtx.setProperty(MessageContext.CLIENT_API_NON_BLOCKING, Boolean.valueOf(!isNonBlocking));
// are these relevant?
//msgCtx.setServiceGroupContextId(UUIDGenerator.getUUID());
// this is required to support Sandesha 2
//msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL,
// new HttpCoreRequestResponseTransport(msgContext));
return msgCtx;
}
示例3: testNoBuilder
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* A builder is not added for the multipart/mixed as in the above test.
* @throws Exception
*/
public void testNoBuilder() throws Exception {
File file = getTestResourceFile("mime_message.txt");
MIMEBuilder mimeBuilder = new MIMEBuilder();
FileInputStream fis = new FileInputStream(file);
ConfigurationContext configContext = ConfigurationContextFactory.createDefaultConfigurationContext();
AxisConfiguration axisConfig = configContext.getAxisConfiguration();
MessageContext mc = new MessageContext();
mc.setConfigurationContext(configContext);
axisConfig.addMessageBuilder("multipart/related", new MIMEBuilder());
axisConfig.addMessageBuilder("application/soap+xml", new SOAPBuilder());
axisConfig.addMessageBuilder("text/xml", new SOAPBuilder());
axisConfig.addMessageBuilder("application/xop+xml", new MTOMBuilder());
axisConfig.addMessageBuilder("application/xml", new ApplicationXMLBuilder());
axisConfig.addMessageBuilder("application/x-www-form-urlencoded",
new XFormURLEncodedBuilder());
axisConfig.addParameter(Constants.Configuration.USE_DEFAULT_FALLBACK_BUILDER, "true");
OMElement envelope = TransportUtils.createSOAPMessage(mc,fis,"multipart/mixed;boundary=--MIMEBoundary258DE2D105298B756D");
assertTrue(envelope != null);
assertTrue(envelope instanceof SOAPEnvelope);
OMElement firstElement = ((SOAPEnvelope)envelope).getBody().getFirstElement();
assertTrue(firstElement instanceof OMSourcedElement);
assertTrue(((OMSourcedElement)firstElement).getDataSource() instanceof UnknownContentOMDataSource);
}
示例4: testEchoXMLSyncMC
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testEchoXMLSyncMC() throws Exception {
AxisOperation opdesc = new OutInAxisOperation(new QName("echoOMElement"));
Options options = new Options();
options.setTo(targetEPR);
options.setAction(operationName.getLocalPart());
options.setTransportInProtocol(Constants.TRANSPORT_TCP);
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://localhost/my", "my");
OMElement method = fac.createOMElement("echoOMElement", omNs);
OMElement value = fac.createOMElement("myValue", omNs);
value.setText("Isaac Asimov, The Foundation Trilogy");
method.addChild(value);
SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope envelope = factory.getDefaultEnvelope();
envelope.getBody().addChild(method);
MessageContext requestContext = new MessageContext();
requestContext.setConfigurationContext(configContext);
requestContext.setAxisService(clientService);
requestContext.setAxisOperation(opdesc);
requestContext.setEnvelope(envelope);
ServiceClient sender = new ServiceClient(configContext, clientService);
sender.setOptions(options);
OperationClient opClient = sender.createClient(new QName("echoOMElement"));
opClient.addMessageContext(requestContext);
opClient.setOptions(options);
opClient.execute(true);
MessageContext response = opClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
SOAPEnvelope env = response.getEnvelope();
assertNotNull(env);
env.getBody().serialize(StAXUtils.createXMLStreamWriter(
System.out));
sender.cleanup();
}
示例5: setUp
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
messageContext = new MessageContext();
axisConfiguration = new AxisConfiguration();
configurationContext = new ConfigurationContext(axisConfiguration);
axisService = new AxisService("Dummy Service");
message = new AxisMessage();
axisOperation = AxisOperationFactory.getAxisOperation(WSDLConstants.MEP_CONSTANT_IN_OUT);
jsonMessageHandler = new JSONMessageHandler();
String fileName = "test-resources/custom_schema/testSchema_2.xsd";
InputStream is = new FileInputStream(fileName);
XmlSchemaCollection schemaCol = new XmlSchemaCollection();
XmlSchema schema = schemaCol.read(new StreamSource(is), null);
QName elementQName = new QName("http://test.json.axis2.apache.org" ,"echoPerson");
message.setDirection(WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
message.setElementQName(elementQName);
message.setParent(axisOperation);
axisOperation.addMessage(message, WSDLConstants.MESSAGE_LABEL_IN_VALUE);
axisService.addSchema(schema);
axisService.addOperation(axisOperation);
SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();
messageContext.setConfigurationContext(configurationContext);
messageContext.setAxisService(axisService);
messageContext.setAxisOperation(axisOperation);
messageContext.setEnvelope(soapEnvelope);
}
示例6: testAddressingMessage
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
protected MessageContext testAddressingMessage(String directory, String testName)
throws Exception {
String testfile = directory + "/" + versionDirectory + "/" + testName;
MessageContext mc = new MessageContext();
mc.setConfigurationContext(ConfigurationContextFactory.createEmptyConfigurationContext());
mc.setEnvelope(TestUtil.getSOAPEnvelope(testfile));
inHandler.invoke(mc);
return mc;
}
示例7: extractAddressingInformationFromHeaders
import org.apache.axis2.context.MessageContext; //导入方法依赖的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;
}
示例8: testMessageWithOmittedHeaders
import org.apache.axis2.context.MessageContext; //导入方法依赖的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();
}
示例9: testDifferentSoapActionProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testDifferentSoapActionProcessing() throws Exception {
String testfile = "valid-messages/" + versionDirectory + "/soapmessage.xml";
MessageContext mc = new MessageContext();
mc.setConfigurationContext(ConfigurationContextFactory.createEmptyConfigurationContext());
mc.setServerSide(true);
try {
mc.setSoapAction("http://ws.apache.org/tests/differentAction");
basicExtractAddressingInformationFromHeaders(testfile, mc);
fail("An AxisFault should have been thrown due to the soapaction being different to the ws-a action.");
}
catch (AxisFault af) {
//Test passed.
}
}
示例10: testSameSoapAction
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testSameSoapAction() throws Exception {
String testfile = "valid-messages/" + versionDirectory + "/soapmessage.xml";
MessageContext mc = new MessageContext();
mc.setConfigurationContext(ConfigurationContextFactory.createEmptyConfigurationContext());
mc.setServerSide(true);
try {
mc.setSoapAction("http://ws.apache.org/tests/action");
basicExtractAddressingInformationFromHeaders(testfile, mc);
}
catch (AxisFault af) {
af.printStackTrace();
log.error(af.getMessage());
fail("An unexpected AxisFault was thrown while testing with a soapaction and ws-a action that are the same.");
}
}
示例11: testEmptySoapAction
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testEmptySoapAction() throws Exception {
String testfile = "valid-messages/" + versionDirectory + "/soapmessage.xml";
MessageContext mc = new MessageContext();
mc.setConfigurationContext(ConfigurationContextFactory.createEmptyConfigurationContext());
try {
mc.setSoapAction("");
basicExtractAddressingInformationFromHeaders(testfile, mc);
}
catch (AxisFault af) {
af.printStackTrace();
log.error(af.getMessage());
fail("An unexpected AxisFault was thrown while testing with an empty soapaction.");
}
}
示例12: testNullSoapAction
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testNullSoapAction() throws Exception {
String testfile = "valid-messages/" + versionDirectory + "/soapmessage.xml";
MessageContext mc = new MessageContext();
mc.setConfigurationContext(ConfigurationContextFactory.createEmptyConfigurationContext());
try {
mc.setSoapAction(null);
basicExtractAddressingInformationFromHeaders(testfile, mc);
}
catch (AxisFault af) {
af.printStackTrace();
log.error(af.getMessage());
fail("An unexpected AxisFault was thrown while testing with a null soapaction.");
}
}
示例13: getFaultForTest
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private AxisFault getFaultForTest(String testName, boolean isSOAP11) throws Exception {
String testfile =
"fault-messages/" + (isSOAP11 ? "soap11" : "soap12") + "/" + testName + ".xml";
SOAPEnvelope envelope = TestUtil.getSOAPEnvelope(testfile);
MessageContext msgContext = new MessageContext();
msgContext.setConfigurationContext(
ConfigurationContextFactory.createEmptyConfigurationContext());
msgContext.setEnvelope(envelope);
AddressingInHandler afih = new AddressingInHandler();
afih.invoke(msgContext);
AddressingInFaultHandler aifh = new AddressingInFaultHandler();
aifh.invoke(msgContext);
return (AxisFault)msgContext.getProperty(Constants.INBOUND_FAULT_OVERRIDE);
}
示例14: testExtractAddressingInformationFromHeadersInvalidCardinality
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private void testExtractAddressingInformationFromHeadersInvalidCardinality(String headerName) {
String testfile = "invalid-cardinality-messages/" + versionDirectory +
"/invalidCardinality" + headerName + "Message.xml";
try {
MessageContext mc = new MessageContext();
mc.setConfigurationContext(
ConfigurationContextFactory.createEmptyConfigurationContext());
try {
basicExtractAddressingInformationFromHeaders(testfile, mc);
fail("An AxisFault should have been thrown due to 2 wsa:" + headerName +
" headers.");
} catch (AxisFault af) {
if (headerName.equals(AddressingConstants.WSA_REPLY_TO)) {
assertNull("No ReplyTo should be set on the MessageContext", mc.getReplyTo());
} else {
assertReplyToEPR(mc.getReplyTo());
}
if (headerName.equals(AddressingConstants.WSA_FAULT_TO)) {
assertNull("No FaultTo should be set on the MessageContext", mc.getFaultTo());
} else {
assertFaultEPR(mc.getFaultTo());
}
if (headerName.equals(AddressingConstants.WSA_ACTION)) {
assertNull("No Action should be set on the MessageContext", mc.getWSAAction());
} else {
assertEquals("WSAAction property is not correct", mc.getWSAAction(), action);
}
if (headerName.equals(AddressingConstants.WSA_MESSAGE_ID)) {
assertNull("No MessageID should be set on the MessageContext",
mc.getMessageID());
} else {
assertEquals("MessageID property is not correct", mc.getMessageID().trim(),
messageID.trim());
}
if (headerName.equals(AddressingConstants.WSA_FROM)) {
assertNull("No From should be set on the MessageContext", mc.getFrom());
} else {
assertFromEPR(mc.getFrom());
}
if (headerName.equals(AddressingConstants.WSA_TO)) {
assertNull("No To should be set on the MessageContext", mc.getTo());
} else {
assertToEPR(mc.getTo());
}
}
} catch (Exception e) {
e.printStackTrace();
log.info(e.getMessage());
fail(" An Exception has occured " + e.getMessage());
}
}