I have created a service and successfully deployed. At client side, I created a ClientMain.java
which only contains a "main" method for the purpose of testing. I tried to use
"MessageContext.getCurrentContext()", but I always get NullPointerException.


Does MessageContext only exist with the service, but not accessible from a client?

This depends a bit on what you do. If you're using the classes generated by wsdl2java on the client side, the MessageContext is not available to your code. And if you think about it it makes sense.


The MessageContext only exists temporarily if you are invoking a web service by calling a generated method. At some point inside this method a MessageContext is created, since we are really in 'the context of a message invcocation'. As soon as the call returns and delivers its result to the caller, the call is finished and the message context is not longer valid since it was used for this single message invocation.

This is only an explanation what happens behind the scenes. I learnt all of that just yestersday, so its pretty fresh.

I also needed a MessageContext on the client side, in my case for serialising a generated structure. My final solution is now to create a MessageContext from scratch by using the following code:

       // Since we are not in a message call context, we have to create a
       // message context ourselves.
       MessageContext mc = new MessageContext( new AxisClient() );

Depending on what you want to solve this may be a solution. In my case, the BeanSerializer and the SerialisationContext work perfectly with this message context.

Hope that helps,
Michael.

_________________________________________________________________
Schützen Sie Ihren Posteingang vor unerwünschten E-Mails. http://www.msn.de/antispam/prevention/junkmailfilter Jetzt Hotmail-Junk-Filter aktivieren!




Reply via email to