本文整理汇总了Java中org.apache.axis2.context.MessageContext.setServiceContext方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.setServiceContext方法的具体用法?Java MessageContext.setServiceContext怎么用?Java MessageContext.setServiceContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.setServiceContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: send
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
protected MessageContext send(ClientOptions options, AxisMessage message, QName operationQName,
boolean block, String resultMessageLabel) throws Exception {
OperationClient mepClient = serviceClient.createClient(operationQName);
MessageContext mc = new MessageContext();
mc.setProperty(Constants.Configuration.MESSAGE_TYPE, message.getMessageType());
mc.setEnvelope(message.getEnvelope());
Attachments attachments = message.getAttachments();
if (attachments != null) {
mc.setAttachmentMap(attachments);
mc.setDoingSwA(true);
mc.setProperty(Constants.Configuration.ENABLE_SWA, true);
}
for (AxisTestClientConfigurator configurator : configurators) {
configurator.setupRequestMessageContext(mc);
}
mc.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, options.getCharset());
mc.setServiceContext(serviceClient.getServiceContext());
if (metrics != null) {
mc.setProperty(BaseConstants.METRICS_COLLECTOR, metrics);
}
mepClient.addMessageContext(mc);
mepClient.execute(block);
// mepClient.complete(mc);
return resultMessageLabel == null ? null : mepClient.getMessageContext(resultMessageLabel);
}
示例2: createMockMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public static MessageContext createMockMessageContext(String payload) throws AxisFault {
MessageContext inMC = new MessageContext();
SOAPEnvelope envelope = OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope();
OMDocument omDoc = OMAbstractFactory.getSOAP11Factory().createOMDocument();
omDoc.addChild(envelope);
envelope.getBody().addChild(TestUtils.createOMElement(payload));
inMC.setEnvelope(envelope);
AxisConfiguration axisConfig = new AxisConfiguration();
AxisService as = new AxisService();
as.setName("ScriptService");
AxisServiceGroup asg = new AxisServiceGroup(axisConfig);
asg.addService(as);
as.addParameter(new Parameter("script.js",
"function invoke(inMC, outMC) { outMC.setPayloadXML(" +
payload + ")}"));
ConfigurationContext cfgCtx = new ConfigurationContext(axisConfig);
ServiceGroupContext sgc = cfgCtx.createServiceGroupContext(asg);
inMC.setAxisService(as);
inMC.setServiceContext(sgc.getServiceContext(as));
return inMC;
}
示例3: createAndFillContexts
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private void createAndFillContexts(AxisService service,
MessageContext msgContext,
SessionContext sessionContext) throws AxisFault {
ServiceGroupContext serviceGroupContext;
AxisServiceGroup axisServiceGroup = service.getAxisServiceGroup();
ConfigurationContext configCtx = msgContext.getConfigurationContext();
serviceGroupContext = configCtx.createServiceGroupContext(axisServiceGroup);
msgContext.setServiceGroupContext(serviceGroupContext);
ServiceContext serviceContext = serviceGroupContext.getServiceContext(service);
msgContext.setServiceContext(serviceContext);
if (sessionContext != null) {
sessionContext.addServiceContext(serviceContext);
sessionContext.addServiceGroupContext(serviceGroupContext);
}
}
示例4: addMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Adds message context to operation context, so that it will handle the logic correctly if the OperationContext
* is null then new one will be created, and Operation Context will become null when some one calls reset().
*
* @param msgContext the MessageContext to add
* @throws AxisFault
*/
@Override
public void addMessageContext(final MessageContext msgContext) throws AxisFault {
msgContext.setServiceContext(sc);
if (msgContext.getMessageID() == null) {
setMessageID(msgContext);
}
axisOp.registerOperationContext(msgContext, oc);
}
示例5: send
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Synchronously send the request and receive a response. This relies on the transport correctly connecting the
* response InputStream!
*
* @param msgContext the request MessageContext to send.
* @return Returns MessageContext.
* @throws AxisFault Sends the message using a two way transport and waits for a response
*/
protected MessageContext send(final MessageContext msgContext) throws AxisFault {
// create the responseMessageContext
final MessageContext responseMessageContext
= msgContext.getConfigurationContext().createMessageContext();
responseMessageContext.setServerSide(false);
responseMessageContext.setOperationContext(msgContext.getOperationContext());
responseMessageContext.setOptions(new Options(options));
responseMessageContext.setMessageID(msgContext.getMessageID());
addMessageContext(responseMessageContext);
responseMessageContext.setServiceContext(msgContext.getServiceContext());
responseMessageContext.setAxisMessage(
axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
//sending the message
AxisEngine.send(msgContext);
responseMessageContext.setDoingREST(msgContext.isDoingREST());
// Copy RESPONSE properties which the transport set onto the request message context when it processed
// the incoming response recieved in reply to an outgoing request.
responseMessageContext.setProperty(MessageContext.TRANSPORT_HEADERS,
msgContext.getProperty(MessageContext.TRANSPORT_HEADERS));
responseMessageContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE));
responseMessageContext.setProperty(MessageContext.TRANSPORT_IN, msgContext
.getProperty(MessageContext.TRANSPORT_IN));
responseMessageContext.setTransportIn(msgContext.getTransportIn());
responseMessageContext.setTransportOut(msgContext.getTransportOut());
handleResponse(responseMessageContext);
return responseMessageContext;
}
示例6: createMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的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;
}
示例7: createMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private MessageContext createMessageContext(OperationContext oc) throws Exception {
MessageContext mc = configurationContext.createMessageContext();
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;
}
示例8: fillContextsFromSessionContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private void fillContextsFromSessionContext(MessageContext msgContext) throws AxisFault {
AxisService service = msgContext.getAxisService();
if (service == null) {
throw new AxisFault(Messages.getMessage("unabletofindservice"));
}
SessionContext sessionContext = msgContext.getSessionContext();
if (sessionContext == null) {
TransportListener listener = msgContext.getTransportIn().getReceiver();
sessionContext = listener.getSessionContext(msgContext);
if (sessionContext == null) {
createAndFillContexts(service, msgContext, sessionContext);
return;
}
}
String serviceGroupName = msgContext.getAxisServiceGroup().getServiceGroupName();
ServiceGroupContext serviceGroupContext =
sessionContext.getServiceGroupContext(serviceGroupName);
if (serviceGroupContext != null) {
//setting service group context
msgContext.setServiceGroupContext(serviceGroupContext);
// setting Service context
msgContext.setServiceContext(serviceGroupContext.getServiceContext(service));
} else {
createAndFillContexts(service, msgContext, sessionContext);
}
ServiceContext serviceContext = sessionContext.getServiceContext(service);
//found the serviceContext from session context , so adding that into msgContext
if (serviceContext != null) {
msgContext.setServiceContext(serviceContext);
serviceContext.setProperty(HTTPConstants.COOKIE_STRING, sessionContext.getCookieID());
}
}
示例9: fillSOAPEnvelope
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Prepare a SOAP envelope with the stuff to be sent.
*
* @param messageContext the message context to be filled
* @param xmlPayload the payload content
* @throws AxisFault if something goes wrong
*/
private void fillSOAPEnvelope(MessageContext messageContext, OMElement xmlPayload)
throws AxisFault {
messageContext.setServiceContext(serviceContext);
SOAPFactory soapFactory = getSOAPFactory();
SOAPEnvelope envelope = soapFactory.getDefaultEnvelope();
if (xmlPayload != null) {
envelope.getBody().addChild(xmlPayload);
}
addHeadersToEnvelope(envelope);
messageContext.setEnvelope(envelope);
}
示例10: send
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Synchronously send the request and receive a response. This relies on the transport
* correctly connecting the response InputStream!
*
* @param msgContext the request MessageContext to send.
* @return Returns MessageContext.
* @throws AxisFault Sends the message using a two way transport and waits for a response
*/
protected MessageContext send(MessageContext msgContext) throws AxisFault {
// create the responseMessageContext
MessageContext responseMessageContext =
msgContext.getConfigurationContext().createMessageContext();
responseMessageContext.setServerSide(false);
responseMessageContext.setOperationContext(msgContext.getOperationContext());
responseMessageContext.setOptions(new Options(options));
responseMessageContext.setMessageID(msgContext.getMessageID());
addMessageContext(responseMessageContext);
responseMessageContext.setServiceContext(msgContext.getServiceContext());
responseMessageContext.setAxisMessage(
axisOp.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
//sending the message
AxisEngine.send(msgContext);
responseMessageContext.setDoingREST(msgContext.isDoingREST());
// Copy RESPONSE properties which the transport set onto the request message context when it processed
// the incoming response recieved in reply to an outgoing request.
responseMessageContext.setProperty(MessageContext.TRANSPORT_HEADERS,
msgContext.getProperty(MessageContext.TRANSPORT_HEADERS));
responseMessageContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE,
msgContext.getProperty(HTTPConstants.MC_HTTP_STATUS_CODE));
responseMessageContext.setProperty(MessageContext.TRANSPORT_IN, msgContext
.getProperty(MessageContext.TRANSPORT_IN));
responseMessageContext.setTransportIn(msgContext.getTransportIn());
responseMessageContext.setTransportOut(msgContext.getTransportOut());
handleResponse(responseMessageContext);
return responseMessageContext;
}
示例11: addMessageContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Adds a message context to the client for processing. This method must not
* process the message - it only records it in the MEP client. Processing
* only occurs when execute() is called.
*
* @param mc the message context
* @throws AxisFault if this is called inappropriately.
*/
public void addMessageContext(MessageContext mc) throws AxisFault {
if (this.mc != null) {
throw new AxisFault(Messages.getMessage("cannotaddmsgctx"));
}
this.mc = mc;
if (mc.getMessageID() == null) {
setMessageID(mc);
}
mc.setServiceContext(sc);
axisOp.registerOperationContext(mc, oc);
this.completed = false;
}
示例12: testMessageContextListener
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Simple test to make verify that the MessageContext listener
* is invoked when a ServiceContext is attached to the MessageContext
* @throws Exception
*/
public void testMessageContextListener() throws Exception {
AxisConfiguration ac = new AxisConfiguration();
ConfigurationContext cc = new ConfigurationContext(ac);
// Create a dummy AxisService
AxisService service = new AxisService();
service.setName("dummy");
AxisServiceGroup asg = new AxisServiceGroup();
asg.addService(service);
// Attach a ServiceContextListener
// The ServiceContextListener will copy sample information from
// the ServiceContext onto the MessageContext
service.addMessageContextListener(new MyMessageContextListener());
// Create a Dummy ServiceContext
ServiceGroupContext sgc = new ServiceGroupContext(cc, asg);
ServiceContext sc = sgc.getServiceContext(service);
sc.setProperty("SERVICE_PROPERTY", "SUCCESSFUL");
// Create a MessageContext
MessageContext mc = new MessageContext();
// Attach the ServiceContext and MessageContext.
// This will trigger the MyServiceContextListener.attachEvent
mc.setServiceContext(sc);
// Verify success
assertTrue("SUCCESSFUL".equals(mc.getProperty("MESSAGE_PROPERTY")));
}
示例13: testCheckUsingAdressingOnClient
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public void testCheckUsingAdressingOnClient() throws Exception {
// Need to create full description hierarchy to prevent NullPointerExceptions
AxisOperation axisOperation = new OutInAxisOperation(new QName("Temp"));
AxisService axisService = new AxisService("Temp");
AxisConfiguration axisConfiguration = new AxisConfiguration();
axisService.addOperation(axisOperation);
axisConfiguration.addService(axisService);
ConfigurationContext configurationContext = new ConfigurationContext(axisConfiguration);
// Make addressing required using the same property as the AddressingConfigurator on the request
MessageContext request = configurationContext.createMessageContext();
request.setProperty(AddressingConstants.ADDRESSING_REQUIREMENT_PARAMETER, AddressingConstants.ADDRESSING_REQUIRED);
// Create a response to invoke the in handler on
MessageContext response = configurationContext.createMessageContext();
// Link the response to the request message context using the context hierarchy
ServiceGroupContext serviceGroupContext = configurationContext.createServiceGroupContext(axisService.getAxisServiceGroup());
ServiceContext serviceContext = serviceGroupContext.getServiceContext(axisService);
OperationContext opContext = axisOperation.findOperationContext(request, serviceContext);
axisOperation.registerOperationContext(request, opContext);
request.setServiceContext(serviceContext);
response.setServiceContext(serviceContext);
request.setOperationContext(opContext);
response.setOperationContext(opContext);
// Invoke the in handler for a response message without addressing headers
response.setEnvelope(TestUtil.getSOAPEnvelope("addressingDisabledTest.xml"));
inHandler.invoke(response);
// Check an exception is thrown by the validation handler because the client
// requires addressing but the response message does not have addressing headers
try {
validationHandler.invoke(response);
fail("An AxisFault should have been thrown due to the absence of addressing headers.");
} catch (AxisFault axisFault) {
// Confirm this is the correct fault
assertEquals("Wrong fault code",
new QName(Final.FAULT_ADDRESSING_HEADER_REQUIRED),
axisFault.getFaultCode());
}
}
示例14: handleResponse
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Retrieves the properties from the proxyOutMessageContext and sets the values to the
* inMessageContext.
*
* @param proxyOutMessageContext the active message context
* @param initialMessageContext the initial message context, which was stored as a property
* in the proxyOutMessageContext
* @throws AxisFault AxisFault
*/
private void handleResponse(MessageContext proxyOutMessageContext, MessageContext initialMessageContext) throws AxisFault {
MessageContext inMessageContext = initialMessageContext.getOperationContext().
getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
// setting the properties
Iterator<String> initialPropertyIterator = proxyOutMessageContext.getPropertyNames();
if (initialPropertyIterator != null) {
while (initialPropertyIterator.hasNext()) {
String strKey = initialPropertyIterator.next();
Object paramObj = proxyOutMessageContext.getProperty(strKey);
if (paramObj != null) {
inMessageContext.setProperty(strKey, paramObj);
}
}
}
inMessageContext.setEnvelope(getEnvelope(proxyOutMessageContext));
inMessageContext.setAxisServiceGroup(initialMessageContext.getAxisServiceGroup());
inMessageContext.setAxisService(initialMessageContext.getAxisService());
inMessageContext.setAxisOperation(initialMessageContext.getAxisOperation());
inMessageContext.setAxisMessage(initialMessageContext.getAxisOperation().getMessage(
WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
inMessageContext.setIncomingTransportName(Constants.TRANSPORT_LOCAL);
inMessageContext.setServiceContext(initialMessageContext.getServiceContext());
// set properties on response
inMessageContext.setServerSide(true);
inMessageContext.setProperty(MessageContext.TRANSPORT_OUT,
initialMessageContext.getProperty(MessageContext.TRANSPORT_OUT));
inMessageContext.setProperty(Constants.OUT_TRANSPORT_INFO,
initialMessageContext.getProperty(Constants.OUT_TRANSPORT_INFO));
inMessageContext.setTransportIn(initialMessageContext.getTransportIn());
inMessageContext.setTransportOut(initialMessageContext.getTransportOut());
if (log.isDebugEnabled()) {
log.debug("Setting AxisServiceGroup - " + initialMessageContext.getAxisServiceGroup());
log.debug("Setting AxisService - " + initialMessageContext.getAxisService());
log.debug("Setting AxisOperation - " + initialMessageContext.getAxisOperation());
log.debug("Setting AxisMessage - " + initialMessageContext.getAxisOperation().
getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
log.debug("Setting Incoming Transport name - " + Constants.TRANSPORT_LOCAL);
log.debug("Setting Service Context " + initialMessageContext.getServiceGroupContext().toString());
log.debug("Setting ServerSide to true");
log.debug("Setting " + MessageContext.TRANSPORT_OUT + " property to " +
initialMessageContext.getProperty(MessageContext.TRANSPORT_OUT));
log.debug("Setting " + Constants.OUT_TRANSPORT_INFO + " property to " +
initialMessageContext.getProperty(Constants.OUT_TRANSPORT_INFO));
log.debug("Setting TransportIn - " + initialMessageContext.getTransportIn());
log.debug("Setting TransportOut - " + initialMessageContext.getTransportOut());
log.debug("Setting ReplyTo - " + initialMessageContext.getReplyTo());
log.debug("Setting FaultTo - " + initialMessageContext.getFaultTo());
}
// copy the message type property that is used by the out message to the response message
inMessageContext.setProperty(Constants.Configuration.MESSAGE_TYPE,
initialMessageContext.getProperty(Constants.Configuration.MESSAGE_TYPE));
if (initialMessageContext.getMessageID() != null) {
inMessageContext.setRelationships(
new RelatesTo[]{new RelatesTo(initialMessageContext.getMessageID())});
}
inMessageContext.setReplyTo(initialMessageContext.getReplyTo());
inMessageContext.setFaultTo(initialMessageContext.getFaultTo());
AxisEngine.receive(inMessageContext);
}
示例15: invoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* @param msgctx
* @throws org.apache.axis2.AxisFault
* @noinspection MethodReturnOfConcreteClass
*/
public InvocationResponse invoke(MessageContext msgctx) throws AxisFault {
InvocationResponse response = InvocationResponse.CONTINUE;
// first check we can dispatch using the relates to
if (msgctx.getRelatesTo() != null) {
String relatesTo = msgctx.getRelatesTo().getValue();
if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
log.debug(msgctx.getLogIDString() + " " + Messages.getMessage("checkingrelatesto",
relatesTo));
}
if (relatesTo != null && !"".equals(relatesTo) && (msgctx.getOperationContext()==null)) {
OperationContext operationContext =
msgctx.getConfigurationContext()
.getOperationContext(relatesTo);
if (operationContext != null) //noinspection TodoComment
{
// if(operationContext.isComplete()){
// // If the dispatch happens because of the RelatesTo and the mep is complete
// // we should throw a more descriptive fault.
// throw new AxisFault(Messages.getMessage("duplicaterelatesto",relatesTo));
// }
msgctx.setAxisOperation(operationContext.getAxisOperation());
msgctx.setAxisMessage(operationContext.getAxisOperation().getMessage(
WSDLConstants.MESSAGE_LABEL_IN_VALUE));
msgctx.setOperationContext(operationContext);
msgctx.setServiceContext((ServiceContext) operationContext.getParent());
msgctx.setAxisService(
((ServiceContext) operationContext.getParent()).getAxisService());
// TODO : Is this necessary here?
msgctx.getAxisOperation().registerMessageContext(msgctx, operationContext);
msgctx.setServiceGroupContextId(
((ServiceGroupContext) msgctx.getServiceContext().getParent()).getId());
if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
log.debug(msgctx.getLogIDString() +
" Dispatched successfully on the RelatesTo. operation=" +
operationContext.getAxisOperation());
}
}
}
}
//Else we will try to dispatch based on the WS-A Action
else {
response = super.invoke(msgctx);
Object flag = msgctx.getLocalProperty(IS_ADDR_INFO_ALREADY_PROCESSED);
if (log.isTraceEnabled()) {
log.trace("invoke: IS_ADDR_INFO_ALREADY_PROCESSED=" + flag);
}
if (JavaUtils.isTrueExplicitly(flag)) {
// If no AxisOperation has been found at the end of the dispatch phase and addressing
// is in use we should throw an ActionNotSupported Fault, unless we've been told
// not to do this check (by Synapse, for instance)
if (JavaUtils.isTrue(msgctx.getProperty(ADDR_VALIDATE_ACTION), true)) {
checkAction(msgctx);
}
}
}
return response;
}