To begin with, let's look at how we can share resources between the request and the response.
If we want to share resources between the request and the response, then the most suitable place is to store the property in the operation context. As we know, there are two different message contexts for the request and the response. If we store a property in the request message context, then it is slightly difficult to access it at the response path. Here's how we can achieve that.
Let's say we store a property called 'Foo' in the request message context. Then how do we access that at the response path? In the response path, we have direct access to the response message context.
OperationContext opCtx = responseMessageContext.getOperationContext();
MessageContext reqMessageContext = opCtx.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
reqMessageContext.getProperty("Foo");
For instance say that we store a property called "Bar" at the request path in the operation context as follows:
OperartionContext opCtx = reqMessageContext.getOperationContext();
opCtx.setProperty("Bar" , "Bar value"); Now we can access the property at the response as follows.
resMessageContext.getProperty("Bar"); If we want to share the resources among the messages, then we need to store the resources or the property in the ServiceContext or ServiceGroupContext.
Apache Axis2/Java - any version