You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Davanum Srinivas <da...@gmail.com> on 2005/08/11 16:15:39 UTC

[Axis2] Response WSA Action

Sanjiva, folks,

I added an init method to inject the MessageContext and I expected
that the following should work, but it doesn't.
msgctx.setWSAAction("http://stockservice.contoso.com/wse/samples/2005/10/GetFileResponse");

What's the best way to set the response WSA Action? I had to set a
property in OperationContext

msgcts.getOperationContext().setProperty(AddressingConstants.WSA_ACTION,"http://stockservice.contoso.com/wse/samples/2005/10/GetFileResponse");

And in Addressing OUT Handler,

if (action == null && msgContext.getOperationContext() != null) {
    action = (String)msgContext.getOperationContext().getProperty(WSA_ACTION);
 }

Am not sure this is the right way...Could you tell me the right way? 

thanks,
dims

-- 
Davanum Srinivas : http://wso2.com/ - Oxygenating The Web Service Platform

Re: [Axis2] Response WSA Action

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
On Thu, 2005-08-11 at 10:15 -0400, Davanum Srinivas wrote:
> Sanjiva, folks,
> 
> I added an init method to inject the MessageContext and I expected
> that the following should work, but it doesn't.
> msgctx.setWSAAction("http://stockservice.contoso.com/wse/samples/2005/10/GetFileResponse");
> 
> What's the best way to set the response WSA Action? I had to set a
> property in OperationContext
> 
> msgcts.getOperationContext().setProperty(AddressingConstants.WSA_ACTION,"http://stockservice.contoso.com/wse/samples/2005/10/GetFileResponse");
> 
> And in Addressing OUT Handler,
> 
> if (action == null && msgContext.getOperationContext() != null) {
>     action = (String)msgContext.getOperationContext().getProperty(WSA_ACTION);
>  }
> 
> Am not sure this is the right way...Could you tell me the right way? 

Its a bit complicated, unfortunately. 

The first problem is that you can't access the response message context
directly from inside a Java class which is invoked by the
InOutMessageReceiver. Why? Because even if you have the MC injected,
what you're getting injected is the *incoming* message context, not the
outgoing one. And because the Java world is about returning the
response, there's no notion of directly accessing the outgoing message
context from the Java code. (This ties in a bit to the long note I
posted about data binding really because this again shows why a Java
method is not the best way to implement an arbitrary MEP in Web
services.)

So what you did first isn't right but what you did 2nd is indeed a
workaround .. you reach up to the operation context and set it there and
then have someone propagate it down (the message receiver would be
better than the addressing handler).

Actually, you can do a bit better, you can reach up to the operation
context and ask for the out message context:

msgContext.getOperationContext().getMessageContext
(WSDLConstants.MESSAGE_LABEL_OUT)

and then set property directly on that message context and then it
should flow out just fine.

I'm 100% certain this works architecturally, but right now I can't find
the call to OperationContext.addMessageContext with the response message
context ... IIUC that needs to be there for the hookup to work as
advertised. That could be a bug (it would have to be in the base
receiver class).

Sanjiva.