You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Jeff Saremi <je...@yahoo.com> on 2005/04/23 19:46:05 UTC

communication between the Handler and the Service

Either there is something i'm not getting or my whole
code/configuration is wrong.

I'd like to intercept a request using a handler,
change something in that request and then let my
service deal with these changes. However, I cannot
this simple, intuitive concept to work! I have spent
over two full days playing with different objects and
different template methods in my service (a message
service) all to no avail.

What i'd like to do is get the XML for the body of the
incoming request in my handler, change some values in
it, and then let my message service deal with the
modified body. But after extensive testing I realized
that the Body that is passed to my Service and the one
i modified in my Handler are completely different!
It's as if Axis makes a copy of the incoming request,
before its modified by my Handler and passes that old
copy to my Service.

Is this true? If not please let me know and i will
send you some more code and configuration for you guys
to examine.

thanks,
jeff

Re: communication between the Handler and the Service

Posted by Jeff Greif <jg...@alumni.princeton.edu>.
This pattern (for one of the jax-rpc handler methods) guarantees that no 
matter what copying takes place, your changes will register.  If your 
handler decides to do nothing with the message, return null from 
whatever you implement for processRequest.  In general it seems that 
items retrieved from MessageContext objects are copies, and must be set 
back into the context after modification.  This applies to properties 
and perhaps other things as well.

    public boolean handleRequest(MessageContext context) {
 
            SOAPMessageContext soapContext = (SOAPMessageContext) context;
            SOAPMessage message = soapContext.getMessage();
            SOAPMessage result = processRequest(message);
            if (result != null) {
                soapContext.setMessage(result);
             }
            return true;
    }

Jeff


Jeff Saremi wrote:

>Either there is something i'm not getting or my whole
>code/configuration is wrong.
>
>I'd like to intercept a request using a handler,
>change something in that request and then let my
>service deal with these changes. However, I cannot
>this simple, intuitive concept to work! I have spent
>over two full days playing with different objects and
>different template methods in my service (a message
>service) all to no avail.
>
>What i'd like to do is get the XML for the body of the
>incoming request in my handler, change some values in
>it, and then let my message service deal with the
>modified body. But after extensive testing I realized
>that the Body that is passed to my Service and the one
>i modified in my Handler are completely different!
>It's as if Axis makes a copy of the incoming request,
>before its modified by my Handler and passes that old
>copy to my Service.
>
>Is this true? If not please let me know and i will
>send you some more code and configuration for you guys
>to examine.
>
>thanks,
>jeff
>
>
>  
>