本文整理汇总了Java中org.apache.axis2.context.MessageContext.getOperationContext方法的典型用法代码示例。如果您正苦于以下问题:Java MessageContext.getOperationContext方法的具体用法?Java MessageContext.getOperationContext怎么用?Java MessageContext.getOperationContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.MessageContext
的用法示例。
在下文中一共展示了MessageContext.getOperationContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPropertyFromMsgCtx
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Helper method to retrieve a property from a specific message context of the operation the given message context
* is part of.
*
* @param currentMsgCtx The current {@link MessageContext}
* @param key The name of the property to get the value for
* @param flow The flow from which the property should be retrieved as integer represented using the
* {@link MessageContext#IN_FLOW} and {@link MessageContext#OUT_FLOW} constants
* @return The value of the requested property if it exists in the out flow message context,or <br>
* <code>null</code> otherwise.
*/
private static Object getPropertyFromMsgCtx(final MessageContext currentMsgCtx, final String key,
final int flow) {
if (currentMsgCtx == null || key == null)
return null;
try {
final OperationContext opContext = currentMsgCtx.getOperationContext();
final MessageContext targetMsgContext = opContext.getMessageContext(flow == MessageContext.IN_FLOW ?
WSDLConstants.MESSAGE_LABEL_IN_VALUE :
WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
return targetMsgContext.getProperty(key);
} catch (final Exception ex) {
return null;
}
}
示例2: invoke
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
public InvocationResponse invoke(MessageContext msgContext) throws AxisFault {
String title = "TempHandler[" + getHandlerID() + "]:invoke(): ";
// get the service context from the message context
ServiceContext serviceContext = msgContext.getServiceContext();
if (serviceContext == null) {
// get the service context from the operation context
OperationContext operationContext = msgContext.getOperationContext();
serviceContext = operationContext.getServiceContext();
}
if (serviceContext != null) {
for (int j = 0; j < numberProperties; j++) {
count++;
String key = new String(propertyKey + ".ID[" + getHandlerID() + "]." + count);
String value = new String(propertyValue + "[" + count + "]");
serviceContext.setProperty(key, value);
}
}
log.debug(title + "executedHandlers.add(" + handlerID + ")");
executedHandlers.add(handlerID);
return InvocationResponse.CONTINUE;
}
示例3: getServiceProperties
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private Map getServiceProperties(MessageContext mc) {
Map properties = null;
// get the service context from the message context
ServiceContext serviceContext = mc.getServiceContext();
if (serviceContext == null) {
// get the service context from the operation context
OperationContext operationContext = mc.getOperationContext();
serviceContext = operationContext.getServiceContext();
}
if (serviceContext != null) {
properties = serviceContext.getProperties();
}
return properties;
}
示例4: getUnderstoodClientHeaders
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Get the collection of Header QNames that are registered as being understood.
* This assumes that a Set of QNames which indicates what headers are "understood" by
* this particular client through the client's programming model (i.e. application
* handlers) has been defined and stored on the outbound MessageContext under the
* client.UnderstoodHeaders property.
* @param msgContext The inbound message context
* @return a Set of Header QNames that have been registered as understood, or null if
* none have been registered.
*/
private static Set getUnderstoodClientHeaders(MessageContext msgContext) {
Set returnQN = null;
// The client sets the property on the JAX-WS Request Message Context, which will be copied
// to the Axis2 outbound message context.
OperationContext opCtx = msgContext.getOperationContext();
MessageContext outboundMC = null;
try {
outboundMC = opCtx.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
}
catch (AxisFault af) {
// Ignore this; it means that there wasn't an outbound message for this operation.
}
if (outboundMC != null) {
returnQN =
(Set) outboundMC.getProperty("client.UnderstoodHeaders");
}
return returnQN;
}
示例5: getCharSetEncoding
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Utility method to query CharSetEncoding. First look in the
* MessageContext. If it's not there look in the OpContext. Use the defualt,
* if it's not given in either contexts.
*
* @param msgContext the active MessageContext
* @return String the CharSetEncoding
*/
public static String getCharSetEncoding(MessageContext msgContext) {
String charSetEnc = (String) msgContext
.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
if (charSetEnc == null) {
OperationContext opctx = msgContext.getOperationContext();
if (opctx != null) {
charSetEnc = (String) opctx
.getProperty(Constants.Configuration.CHARACTER_SET_ENCODING);
}
/**
* If the char set enc is still not found use the default
*/
if (charSetEnc == null) {
charSetEnc = MessageContext.DEFAULT_CHAR_SET_ENCODING;
}
}
return charSetEnc;
}
示例6: setupCorrectTransportOut
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Ensure that if the scheme of the To EPR for the response is different than the
* transport used for the request that the correct TransportOut is available
*/
private static void setupCorrectTransportOut(MessageContext context) throws AxisFault {
// Determine that we have the correct transport available.
TransportOutDescription transportOut = context.getTransportOut();
try {
EndpointReference responseEPR = context.getTo();
if (context.isServerSide() && responseEPR != null) {
if (!responseEPR.hasAnonymousAddress() && !responseEPR.hasNoneAddress()) {
URI uri = new URI(responseEPR.getAddress());
String scheme = uri.getScheme();
if ((transportOut == null) || !transportOut.getName().equals(scheme)) {
ConfigurationContext configurationContext =
context.getConfigurationContext();
transportOut = configurationContext.getAxisConfiguration()
.getTransportOut(scheme);
if (transportOut == null) {
throw new AxisFault("Can not find the transport sender : " + scheme);
}
context.setTransportOut(transportOut);
}
if (context.getOperationContext() != null) {
context.getOperationContext().setProperty(
Constants.DIFFERENT_EPR, Constants.VALUE_TRUE);
}
}
}
} catch (URISyntaxException urise) {
throw AxisFault.makeFault(urise);
}
}
示例7: waitForSynchronousResponse
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Should the transport sender wait for a synchronous response to be received?
* @param msgCtx the outgoing message context
* @return true if a sync response is expected
*/
protected boolean waitForSynchronousResponse(MessageContext msgCtx) {
return
msgCtx.getOperationContext() != null &&
WSDL2Constants.MEP_URI_OUT_IN.equals(
msgCtx.getOperationContext().getAxisOperation().getMessageExchangePattern());
}
示例8: findForExistingOperationContext
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Returns as existing OperationContext related to this message if one exists.
* <p/>
* TODO - why both this and findOperationContext()? (GD)
*
* @param msgContext the MessageContext for which we'd like an OperationContext
* @return the OperationContext, or null
* @throws AxisFault
*/
public OperationContext findForExistingOperationContext(MessageContext msgContext)
throws AxisFault {
OperationContext operationContext;
if ((operationContext = msgContext.getOperationContext()) != null) {
return operationContext;
}
// If this message is not related to another one, or it is but not one emitted
// from the same operation, don't further look for an operation context or fault.
if (null != msgContext.getRelatesTo()) {
// So this message may be part of an ongoing MEP
ConfigurationContext configContext = msgContext.getConfigurationContext();
operationContext =
configContext.getOperationContext(msgContext.getRelatesTo().getValue());
if (null == operationContext && log.isDebugEnabled()) {
log.debug(msgContext.getLogIDString() +
" Cannot correlate inbound message RelatesTo value [" +
msgContext.getRelatesTo() + "] to in-progree MEP");
}
}
return operationContext;
}
示例9: cacheNewResponse
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private void cacheNewResponse(MessageContext msgContext,
String serviceName, String requestHash,
CacheConfiguration chCfg) {
CachableResponse response = new CachableResponse();
response.setRequestHash(requestHash);
response.setTimeout(chCfg.getTimeout());
OperationContext opCtx = msgContext.getOperationContext();
opCtx.setNonReplicableProperty(CachingConstants.CACHED_OBJECT, response);
}
示例10: waitForSynchronousResponse
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* Should the transport sender wait for a synchronous response to be received?
* @param msgCtx the outgoing message context
* @return true if a sync response is expected
*/
protected boolean waitForSynchronousResponse(MessageContext msgCtx) {
boolean waitingState = false;
if (msgCtx.getOperationContext() != null) {
String MEP = msgCtx.getOperationContext().getAxisOperation().getMessageExchangePattern();
waitingState = "http://www.w3.org/ns/wsdl/out-in".equals(MEP) ||
"http://www.w3.org/ns/wsdl/in-out".equals(MEP);
}
return waitingState;
}
示例11: triggerAddressingFault
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private static void triggerAddressingFault(MessageContext messageContext,
String faultInformationKey,
Object faultInformationValue, String faultcode,
String faultSubcode, String faultReason)
throws AxisFault {
Map faultInformation =
(Map)messageContext.getLocalProperty(Constants.FAULT_INFORMATION_FOR_HEADERS);
if (faultInformation == null) {
faultInformation = new HashMap();
messageContext.setProperty(Constants.FAULT_INFORMATION_FOR_HEADERS, faultInformation);
}
faultInformation.put(faultInformationKey, faultInformationValue);
if (messageContext.isSOAP11()) {
faultcode = (faultSubcode != null) ? faultSubcode : faultcode;
} else {
setFaultCode(messageContext, faultcode, faultSubcode);
}
OperationContext oc = messageContext.getOperationContext();
if (oc != null) {
oc.setProperty(Constants.Configuration.SEND_STACKTRACE_DETAILS_WITH_FAULTS, "false");
}
messageContext.setProperty(AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES,
Boolean.FALSE);
String namespace =
(String)messageContext.getProperty(AddressingConstants.WS_ADDRESSING_VERSION);
throw new AxisFault(faultReason, new QName(namespace, faultcode,
AddressingConstants.WSA_DEFAULT_PREFIX));
}
示例12: getRequestResponseTransport
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
/**
* This is an internal helper method to retrieve the RequestResponseTransport instance
* from the MessageContext object. The MessageContext may be the response MessageContext so
* in that case we will have to retrieve the request MessageContext from the OperationContext.
*/
private static RequestResponseTransport getRequestResponseTransport(MessageContext messageContext) {
try {
// If this is the request MessageContext we should find it directly by the getProperty()
// method
RequestResponseTransport transportControl = (RequestResponseTransport)
messageContext.getProperty(RequestResponseTransport.TRANSPORT_CONTROL);
if (transportControl != null) {
return transportControl;
}
// If this is the response MessageContext we need to look for the request MessageContext
else if (messageContext.getOperationContext() != null
&& messageContext.getOperationContext()
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE) != null) {
return (RequestResponseTransport) messageContext.
getOperationContext().getMessageContext(
WSDLConstants.MESSAGE_LABEL_IN_VALUE).getProperty(
RequestResponseTransport.TRANSPORT_CONTROL);
}
else {
return null;
}
}
catch(AxisFault af) {
// probably should not be fatal, so just log the message
String msg = Messages.getMessage("getMessageContextError", af.toString());
log.debug(msg);
return null;
}
}
示例13: doProcessing
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Override
protected InvocationResponse doProcessing(final MessageContext mc) throws AxisFault {
SOAPEnvelope env = null;
// SOAP Envelope only needs to be created when Holodeck B2B initiates the exchange
// or when response does not yet contain one
if ((isInFlow(RESPONDER) && (env = mc.getEnvelope()) == null) || isInFlow(INITIATOR)) {
// For request use P-Mode, for response use SOAP version from request
log.debug("Check for SOAP version");
SOAPEnv.SOAPVersion version;
if (isInFlow(INITIATOR)) {
log.debug("Use P-Mode of primary message unit to get SOAP version");
final IMessageUnitEntity primaryMU = MessageContextUtils.getPrimaryMessageUnit(mc);
if (primaryMU == null) {
log.debug("No message unit in this response, no envelope needed");
return InvocationResponse.CONTINUE;
}
final IPMode pmode = HolodeckB2BCoreInterface.getPModeSet().get(primaryMU.getPModeId());
// Currently only One-Way MEPs are supported, so always on first leg
final ILeg leg = pmode.getLeg(primaryMU.getLeg());
version = leg.getProtocol() != null && "1.1".equals(leg.getProtocol().getSOAPVersion()) ?
SOAPEnv.SOAPVersion.SOAP_11 : SOAPEnv.SOAPVersion.SOAP_12;
} else {
log.debug("Get version from request context");
final OperationContext opContext = mc.getOperationContext();
final MessageContext reqMsgContext = opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
version = (reqMsgContext.isSOAP11() ? SOAPEnv.SOAPVersion.SOAP_11 : SOAPEnv.SOAPVersion.SOAP_12);
}
log.debug("Create SOAP " + (version == SOAPEnv.SOAPVersion.SOAP_11 ? "1.1" : "1.2") + " envelope");
env = SOAPEnv.createEnvelope(version);
try {
// Add the new SOAP envelope to the message context and continue processing
mc.setEnvelope(env);
} catch (final AxisFault ex) {
log.fatal("Could not add the SOAP envelope to the message!");
throw new AxisFault("Could not add the SOAP envelope to the message!");
}
log.debug("Added SOAP envelope to message context");
} else {
log.debug("Check that ebMS namespace is declared on the SOAP envelope");
SOAPEnv.declareNamespaces(env);
}
log.debug("Add empty eb3:Messaging element");
final SOAPHeaderBlock messaging = Messaging.createElement(env);
return InvocationResponse.CONTINUE;
}
示例14: flowComplete
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
@Override
// Handle IN_ONLY operations
public void flowComplete(MessageContext msgContext) {
if (msgContext.getEnvelope() == null) {
return;
}
AxisService axisService = msgContext.getAxisService();
if (axisService == null ||
SystemFilter.isFilteredOutService(axisService.getAxisServiceGroup()) ||
axisService.isClientSide()) {
return;
}
try {
// Process Request Counter
OperationContext opContext = msgContext.getOperationContext();
if (opContext != null && opContext.isComplete()) {
AxisOperation axisOp = opContext.getAxisOperation();
if (axisOp != null && axisOp.isControlOperation()) {
return;
}
if (axisOp != null) {
String mep = axisOp.getMessageExchangePattern();
if (mep != null &&
(mep.equals(WSDL2Constants.MEP_URI_IN_ONLY) ||
mep.equals(WSDL2Constants.MEP_URI_ROBUST_IN_ONLY))) {
// Increment operation counter
final AxisOperation axisOperation = msgContext.getAxisOperation();
if (axisOperation != null) {
Parameter operationParameter =
axisOperation.getParameter(StatisticsConstants.IN_OPERATION_COUNTER);
if (operationParameter != null) {
((AtomicInteger) operationParameter.getValue()).incrementAndGet();
} else {
log.error(StatisticsConstants.IN_OPERATION_COUNTER +
" has not been set for operation " +
axisService.getName() + "." + axisOperation.getName());
return;
}
// Calculate response times
try {
ResponseTimeCalculator.calculateResponseTimes(msgContext);
} catch (AxisFault axisFault) {
log.error("Cannot compute response times", axisFault);
}
}
// Increment global counter
Parameter globalRequestCounter =
msgContext.getParameter(StatisticsConstants.GLOBAL_REQUEST_COUNTER);
((AtomicInteger) globalRequestCounter.getValue()).incrementAndGet();
updateCurrentInvocationGlobalStatistics(msgContext);
}
}
}
} catch (Throwable e) { // Catching Throwable since exceptions here should not be propagated up
log.error("Could not call InOnlyMEPHandler.flowComplete", e);
}
}
示例15: getMessageSequence
import org.apache.axis2.context.MessageContext; //导入方法依赖的package包/类
private long getMessageSequence(String serviceName, String operationName,
MessageContext msgContext, long msgSequenceNumber) {
long msgSequence = 1;
// check whether this is a continuation of an existing MEP
synchronized (serviceName + operationName) {
OperationContext operationContext = msgContext.getOperationContext();
Object requestNumber = null;
if (operationContext != null) {
requestNumber = operationContext.getProperty(REQUEST_NUMBER);
} else if (msgSequenceNumber != -1) {
requestNumber = msgSequenceNumber;
}
if ((requestNumber != null) && requestNumber instanceof Long) {
msgSequence = ((Long) requestNumber).intValue();
} else {
// Need to have a counter for each and operation
Map monitoringHandlerMap =
(Map) msgContext.getConfigurationContext().getProperty(TRACING_MAP);
if (monitoringHandlerMap == null) {
monitoringHandlerMap = new HashMap();
msgContext.getConfigurationContext().setProperty(TRACING_MAP,
monitoringHandlerMap);
}
String key = serviceName + "." + operationName;
Object counterInt = monitoringHandlerMap.get(key);
if (counterInt == null) {
msgSequence = 0;
} else if (counterInt instanceof Long) {
msgSequence = ((Long) counterInt).intValue() + 1;
}
monitoringHandlerMap.put(key, msgSequence);
if (operationContext != null) {
operationContext.setProperty(REQUEST_NUMBER, msgSequence);
}
}
}
return msgSequence;
}