本文整理汇总了Java中org.apache.axis2.context.OperationContext.getMessageContext方法的典型用法代码示例。如果您正苦于以下问题:Java OperationContext.getMessageContext方法的具体用法?Java OperationContext.getMessageContext怎么用?Java OperationContext.getMessageContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.axis2.context.OperationContext
的用法示例。
在下文中一共展示了OperationContext.getMessageContext方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gzipCompressionInsideOutSequenceTest
import org.apache.axis2.context.OperationContext; //导入方法依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "having 'Content-Encoding = gzip' within outsequence")
public void gzipCompressionInsideOutSequenceTest() throws Exception {
ServiceClient client = getServiceClient(getProxyServiceURLHttp("sendingGZIPCompressedPayloadToClient"));
client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, true);
OMElement response = client.sendReceive(Utils.getStockQuoteRequest("GZIP"));
OperationContext operationContext = client.getLastOperationContext();
MessageContext inMessageContext = operationContext.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
CommonsTransportHeaders transportHeaders = (CommonsTransportHeaders) inMessageContext.getProperty(TRANSPORT_HEADERS);
Assert.assertTrue(transportHeaders.containsKey(CONTENT_ENCODING), "Response Message not encoded");
Assert.assertEquals(transportHeaders.get(CONTENT_ENCODING), "gzip", "Response Message not gzip encoded");
Assert.assertTrue(response.toString().contains("GZIP"));
Assert.assertTrue(response.toString().contains("GZIP Company"));
}
示例2: createResponseMessageContext
import org.apache.axis2.context.OperationContext; //导入方法依赖的package包/类
/**
* Creates the {@link MessageContext} for the response to message currently being processed.
*
* @param reqContext The MessageContext of the received message
* @return The MessageContext for the response message
*/
public static MessageContext createResponseMessageContext(final MessageContext reqContext) {
try {
MessageContext resCtx = null;
// First try to get the context for the response from the OperationContext
final OperationContext opContext = reqContext.getOperationContext();
if (opContext != null) {
resCtx = opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
}
// If that fails, construct a new context
if (resCtx == null) {
resCtx = MessageContextBuilder.createOutMessageContext(reqContext);
resCtx.getOperationContext().addMessageContext(resCtx);
}
return resCtx;
} catch (final AxisFault af) {
// Somewhere the construction of the new MessageContext failed
return null;
}
}
示例3: getPropertyFromMsgCtx
import org.apache.axis2.context.OperationContext; //导入方法依赖的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;
}
}
示例4: getRelatedMessageContext
import org.apache.axis2.context.OperationContext; //导入方法依赖的package包/类
/**
* getRelatedMessageContext
* @param mc Axis2 MessageContext
* @return related MessageContext
*/
private static org.apache.axis2.context.MessageContext
getRelatedMessageContext(org.apache.axis2.context.MessageContext mc) {
if (log.isDebugEnabled()) {
log.debug("Enter getRelatedMessageContext for:" + mc);
}
org.apache.axis2.context.MessageContext relatedMC = null;
if (mc != null) {
OperationContext oc = mc.getOperationContext();
if (oc != null) {
try {
relatedMC = oc.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
if (relatedMC == mc) {
relatedMC = oc.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
}
} catch (AxisFault e) {
// TODO This should never occur in this scenario, swallow and continue
}
}
}
if (log.isDebugEnabled()) {
log.debug("Exit getRelatedMessageContext related messageContext is" + relatedMC);
}
return relatedMC;
}
示例5: getRelatedMessageContext
import org.apache.axis2.context.OperationContext; //导入方法依赖的package包/类
/**
* @param mc
* @return
*/
private static MessageContext getRelatedMessageContext(MessageContext mc) {
if (log.isDebugEnabled()) {
log.debug("Enter getRelatedMessageContext for:" + mc);
}
MessageContext relatedMC = null;
if (mc != null) {
OperationContext oc = mc.getOperationContext();
if (oc != null) {
try {
relatedMC = oc.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
if (relatedMC == mc) {
relatedMC = oc.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
}
} catch (AxisFault e) {
// TODO This should never occur in this scenario, swallow and continue
}
}
}
if (log.isDebugEnabled()) {
log.debug("Exit getRelatedMessageContext related messageContext is" + relatedMC);
}
return relatedMC;
}
示例6: getUnderstoodClientHeaders
import org.apache.axis2.context.OperationContext; //导入方法依赖的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;
}
示例7: gzipCompressionBothInAndOutSequencesTest
import org.apache.axis2.context.OperationContext; //导入方法依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "having 'Content-Encoding = gzip' within both in and out sequences and accepting gzip response")
public void gzipCompressionBothInAndOutSequencesTest() throws Exception {
ServiceClient client = getServiceClient(getProxyServiceURLHttp("sendAndReceiveGZIPCompressedPayload"));
client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, true);
OMElement response = client.sendReceive(Utils.getStockQuoteRequest("GZIP"));
OperationContext operationContext = client.getLastOperationContext();
MessageContext inMessageContext = operationContext.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
CommonsTransportHeaders transportHeaders = (CommonsTransportHeaders) inMessageContext.getProperty(TRANSPORT_HEADERS);
Assert.assertTrue(transportHeaders.containsKey(CONTENT_ENCODING), "Response Message not encoded");
Assert.assertEquals(transportHeaders.get(CONTENT_ENCODING), "gzip", "Response Message not gzip encoded");
Assert.assertTrue(response.toString().contains("GZIP"));
Assert.assertTrue(response.toString().contains("GZIP Company"));
}
示例8: sendingAndReceivingGzipCompressedPayloadTest
import org.apache.axis2.context.OperationContext; //导入方法依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "having 'Accept-Encoding = gzip' within both in and out sequences")
public void sendingAndReceivingGzipCompressedPayloadTest() throws Exception {
ServiceClient client = getServiceClient(getProxyServiceURLHttp("sendingGZIPCompressedPayloadToClient"));
client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_GZIP_REQUEST, true);
client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, true);
OMElement response = client.sendReceive(Utils.getStockQuoteRequest("GZIP"));
OperationContext operationContext = client.getLastOperationContext();
MessageContext inMessageContext = operationContext.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
CommonsTransportHeaders transportHeaders = (CommonsTransportHeaders) inMessageContext.getProperty(TRANSPORT_HEADERS);
Assert.assertTrue(transportHeaders.containsKey(CONTENT_ENCODING), "Response Message not encoded");
Assert.assertEquals(transportHeaders.get(CONTENT_ENCODING), "gzip", "Response Message not gzip encoded");
Assert.assertTrue(response.toString().contains("GZIP"));
Assert.assertTrue(response.toString().contains("GZIP Company"));
}
示例9: sendingAndReceivingGzipCompressedRequestInAllPathTest
import org.apache.axis2.context.OperationContext; //导入方法依赖的package包/类
@Test(groups = {"wso2.esb"}, description = "sending and accepting gzip compressed payload")
public void sendingAndReceivingGzipCompressedRequestInAllPathTest() throws Exception {
ServiceClient client = getServiceClient(getProxyServiceURLHttp("sendAndReceiveGZIPCompressedPayload"));
client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_GZIP_REQUEST, true);
client.getOptions().setProperty(org.apache.axis2.transport.http.HTTPConstants.MC_ACCEPT_GZIP, true);
OMElement response = client.sendReceive(Utils.getStockQuoteRequest("GZIP"));
OperationContext operationContext = client.getLastOperationContext();
MessageContext inMessageContext = operationContext.getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
CommonsTransportHeaders transportHeaders = (CommonsTransportHeaders) inMessageContext.getProperty(TRANSPORT_HEADERS);
Assert.assertTrue(transportHeaders.containsKey(CONTENT_ENCODING), "Response Message not encoded");
Assert.assertEquals(transportHeaders.get(CONTENT_ENCODING), "gzip", "Response Message not gzip encoded");
Assert.assertTrue(response.toString().contains("GZIP"));
Assert.assertTrue(response.toString().contains("GZIP Company"));
}
示例10: getResponseEnvelope
import org.apache.axis2.context.OperationContext; //导入方法依赖的package包/类
private SOAPEnvelope getResponseEnvelope(ServiceClient client) throws AxisFault {
OperationContext operationContext = client.getLastOperationContext();
MessageContext messageContext =
operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
if (messageContext != null) {
return messageContext.getEnvelope();
}
return null;
}
示例11: setOperationContext
import org.apache.axis2.context.OperationContext; //导入方法依赖的package包/类
public void setOperationContext(OperationContext opCtx)
throws AxisFault {
inMesasgeContext = opCtx.getMessageContext(
WSDLConstants.MESSAGE_LABEL_IN_VALUE);
}
示例12: doProcessing
import org.apache.axis2.context.OperationContext; //导入方法依赖的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;
}
示例13: handleResponse
import org.apache.axis2.context.OperationContext; //导入方法依赖的package包/类
/**
* Used to handle the HTTP Response
*
* @param msgContext - The MessageContext of the message
* @param method - The HTTP method used
* @throws IOException - Thrown in case an exception occurs
*/
private void handleResponse(MessageContext msgContext,
HttpMethodBase method) throws IOException {
int statusCode = method.getStatusCode();
HTTPStatusCodeFamily family = getHTTPStatusCodeFamily(statusCode);
log.trace("Handling response - " + statusCode);
Set<Integer>nonErrorCodes = (Set<Integer>) msgContext.getProperty(HTTPConstants.NON_ERROR_HTTP_STATUS_CODES);
Set<Integer> errorCodes = new HashSet<Integer>();
String strRetryErrorCodes = (String) msgContext.getProperty(HTTPConstants.ERROR_HTTP_STATUS_CODES); // Fixing
// ESBJAVA-3178
if (strRetryErrorCodes != null && !strRetryErrorCodes.trim().equals("")) {
for (String strRetryErrorCode : strRetryErrorCodes.split(",")) {
try {
errorCodes.add(Integer.valueOf(strRetryErrorCode));
} catch (NumberFormatException e) {
log.warn(strRetryErrorCode + " is not a valid status code");
}
}
}
if (HTTPStatusCodeFamily.SUCCESSFUL.equals(family)) {
// Save the HttpMethod so that we can release the connection when cleaning up
// HTTP 202 Accepted should support body based on ESBJAVA-4370 as spec does not strictly enforce
// no-entity-body with 202 Accepted response.
msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
processResponse(method, msgContext);
} else if (!errorCodes.contains(statusCode)
&& (statusCode == HttpStatus.SC_INTERNAL_SERVER_ERROR
|| statusCode == HttpStatus.SC_BAD_REQUEST || statusCode == HttpStatus.SC_CONFLICT)) {
// Save the HttpMethod so that we can release the connection when cleaning up
msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
Header contenttypeHeader =
method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);
String value = null;
if (contenttypeHeader != null) {
value = contenttypeHeader.getValue();
}
OperationContext opContext = msgContext.getOperationContext();
if(opContext!=null){
MessageContext inMessageContext =
opContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
if(inMessageContext!=null){
inMessageContext.setProcessingFault(true);
}
}
if (value != null) {
processResponse(method, msgContext);
}
if (org.apache.axis2.util.Utils.isClientThreadNonBlockingPropertySet(msgContext)) {
throw new AxisFault(Messages.getMessage("transportError",
String.valueOf(statusCode),
method.getStatusText()));
}
} else if (nonErrorCodes != null && nonErrorCodes.contains(statusCode)) {
msgContext.setProperty(HTTPConstants.HTTP_METHOD, method);
processResponse(method, msgContext);
return;
} else {
// Since we don't process the response, we must release the connection immediately
method.releaseConnection();
//solving CARBON-16056
msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE, method.getStatusCode());
AxisFault axisFault = new AxisFault(
Messages.getMessage("transportError", String.valueOf(statusCode), method.getStatusText()),
msgContext);
axisFault.setFaultCode(String.valueOf(method.getStatusCode()));
throw axisFault;
}
}
示例14: cleanupTransport
import org.apache.axis2.context.OperationContext; //导入方法依赖的package包/类
/**
* Release resources allocated by the transport during the last service invocation.
* This method will call
* {@link org.apache.axis2.transport.TransportSender#cleanup(MessageContext)} on the
* transport sender used during that invocation.
* <p>
* If the <code>callTransportCleanup</code> property on the {@link Options} object is
* set to <code>false</code> (which is the default), then this method must be called
* after each invocation of an operation with an in-out MEP, but not before the response
* from that operation has been completely processed (or {@link OMElement#build()}
* has been called on the response element).
* <p>
* If the <code>callTransportCleanup</code> property is set to <code>true</code>,
* then this method is called automatically. Note that in this case, {@link OMElement#build()}
* will be called on the response element before is returned. This effectively disables
* deferred parsing of the response and prevents the code from starting to process the
* response before it has been completely received. Therefore this approach is not recommended
* whenever performance is important.
*
* @throws AxisFault
*/
public void cleanupTransport() throws AxisFault {
final OperationContext lastOperationContext = getLastOperationContext();
if (lastOperationContext != null) {
MessageContext outMessageContext =
lastOperationContext
.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
if (outMessageContext != null) {
if (outMessageContext.getTransportOut() != null &&
outMessageContext.getTransportOut().getSender() != null) {
outMessageContext.getTransportOut().getSender().cleanup(outMessageContext);
}
}
}
}