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 Jean-Francois Denise - Sun Microsystems <je...@sun.com> on 2004/07/27 15:03:20 UTC

Deserialization of received message question

I found a problem when accessing header.

Context : webservices exposed dynamicaly (WSDL and implementation).

In order to define which service is in the scope of a received request, 
I need to access an Header.

I access the header when Axis calls my own instance of 
EngineConfiguration.getService(QName name).

I use Message.getSOAPEnvelope().getHeaderByName(...) I noticed that 
calling getSOAPEnvelope launches the full message deserialization. The 
body is also deserialized.

In case of WRAPPED/LITERAL this is a problem. The metadata (mainly types 
of the service operations) used to create the service ServiceDesc
are not known when this deserialization occurs. Axis is deserializing 
the literal values in "best effort" (String for simple types, ...)

I perhaps access the header in the wrong place. This could sound strange 
but I need to access the header in order to findout what is the service.

I found a way to do it but it smells the hack... I create a new Message 
from the received one. Call getSOAPEnvelope() on the newly created one.
The deserialization is done twice...

 Message msg = msgContext.getRequestMessage();
 Message msg2 = new Message(msg.getSOAPPartAsString());
 SOAPEnvelope env = msg2.getSOAPEnvelope();


Regards.

-- 
----------------------------------------------------------------------
Jean-Francois Denise            Sun Microsystems
Sun ONE/Java Web Services
email: jfd@sun.com 
Internal home page : http://icncweb.france/~jfdenise
-------------------------------------------------------------------


Re: Deserialization of received message question

Posted by Jean-Francois Denise - Sun Microsystems <je...@sun.com>.
Thanks for your reply.

There is something that I still don't understand. I will try to express 
my understanding of what AXIS runtime is doing when a request is 
received then try to explain what is going on in my request flow handling.

Typical scenario :
1) A request is received.
2) The "Handler stack" is called whatever the SOAPService provider type.
3) If a target service has been set by an handler, the method 
getService(qname) is called. It expects a SOAPService to be returned.
4) IMPORTANT STEP :  At some point before entering the provider, the 
deserialization task is done. It seems to be resulting AxisServer.invoke 
Message manipulation (SOAPEnvelope is accessed so deserialized)
5) The request enters the provider (MsgProvider, RPCProvider, ...)

My request flow:
1) Switch to MsgProvider
2) Have a transport handler that returns an hardcoded serviceName (not 
derived from header nor URL)
3) Return a service without initialized serviceDesc in getService(qName)

4) IMPORTANT STEP : The AxisServer.invoke will make SOAPEnvelope to be 
deserialized (like in typical scenario)

5) Access to the header or URL in processMessage to findout the needed 
informations to construct the serviceDesc
6) Set the serviceDesc in the service
7) Findout the body
8) Call body.getParams() (This step is where I expect the 
deserialization based on a fully initialized SOAPService to be done).

==>Values of the deserialized parameters don't follow the serviceDesc I 
provided. So it doen't work

If the returned SOAPService in step 3) contains a valid serviceDesc, 
everything is OK.


Thanks for your help.


Anne Thomas Manes wrote:

>MsgProvider deserializes the message into a DOM rather than into Java
>objects.
>
>-----Original Message-----
>From: Jean-Francois Denise - Sun Microsystems
>[mailto:jean-francois.denise@sun.com] 
>Sent: Tuesday, July 27, 2004 9:47 AM
>To: axis-user@ws.apache.org
>Subject: Re: Deserialization of received message question
>
>Today my dynamic provider extends RPCProvider and overrides 
>processMessage. It can generate WSDL for interfaces of running JMX 
>MBeans as well as routing requests to MBean instances.
>
>Looking at MsgProvider, I noticed that the SOAPEnvelope is a 
>processMessage parameter.
>It seems to me that, when processMessage is called, the message has 
>already been deserialized?
>If it is the case, I will have the same problem. I have the feeling that 
>I have something wrong here.
>
>
>
>Davanum Srinivas wrote:
>
>  
>
>>This is definitely a hack, i don't recommend using it this way. Do you
>>want to experiment a bit with MsgProvider? It's designed specifically
>>for delivering the DOM to your service.
>>
>>-- dims
>>
>>On Tue, 27 Jul 2004 15:03:20 +0200, Jean-Francois Denise - Sun
>>Microsystems <je...@sun.com> wrote:
>> 
>>
>>    
>>
>>>I found a problem when accessing header.
>>>
>>>Context : webservices exposed dynamicaly (WSDL and implementation).
>>>
>>>In order to define which service is in the scope of a received request,
>>>I need to access an Header.
>>>
>>>I access the header when Axis calls my own instance of
>>>EngineConfiguration.getService(QName name).
>>>
>>>I use Message.getSOAPEnvelope().getHeaderByName(...) I noticed that
>>>calling getSOAPEnvelope launches the full message deserialization. The
>>>body is also deserialized.
>>>
>>>In case of WRAPPED/LITERAL this is a problem. The metadata (mainly types
>>>of the service operations) used to create the service ServiceDesc
>>>are not known when this deserialization occurs. Axis is deserializing
>>>the literal values in "best effort" (String for simple types, ...)
>>>
>>>I perhaps access the header in the wrong place. This could sound strange
>>>but I need to access the header in order to findout what is the service.
>>>
>>>I found a way to do it but it smells the hack... I create a new Message
>>>      
>>>
>>>from the received one. Call getSOAPEnvelope() on the newly created one.
>>    
>>
>>>The deserialization is done twice...
>>>
>>>Message msg = msgContext.getRequestMessage();
>>>Message msg2 = new Message(msg.getSOAPPartAsString());
>>>SOAPEnvelope env = msg2.getSOAPEnvelope();
>>>
>>>Regards.
>>>
>>>--
>>>----------------------------------------------------------------------
>>>Jean-Francois Denise            Sun Microsystems
>>>Sun ONE/Java Web Services
>>>email: jfd@sun.com
>>>Internal home page : http://icncweb.france/~jfdenise
>>>-------------------------------------------------------------------
>>>
>>>
>>>   
>>>
>>>      
>>>
>> 
>>
>>    
>>
>
>
>  
>


-- 
----------------------------------------------------------------------
Jean-Francois Denise            Sun Microsystems
Sun ONE/Java Web Services
email: jfd@sun.com 
Internal home page : http://icncweb.france/~jfdenise
-------------------------------------------------------------------


RE: Deserialization of received message question

Posted by Anne Thomas Manes <an...@manes.net>.
MsgProvider deserializes the message into a DOM rather than into Java
objects.

-----Original Message-----
From: Jean-Francois Denise - Sun Microsystems
[mailto:jean-francois.denise@sun.com] 
Sent: Tuesday, July 27, 2004 9:47 AM
To: axis-user@ws.apache.org
Subject: Re: Deserialization of received message question

Today my dynamic provider extends RPCProvider and overrides 
processMessage. It can generate WSDL for interfaces of running JMX 
MBeans as well as routing requests to MBean instances.

Looking at MsgProvider, I noticed that the SOAPEnvelope is a 
processMessage parameter.
It seems to me that, when processMessage is called, the message has 
already been deserialized?
If it is the case, I will have the same problem. I have the feeling that 
I have something wrong here.



Davanum Srinivas wrote:

>This is definitely a hack, i don't recommend using it this way. Do you
>want to experiment a bit with MsgProvider? It's designed specifically
>for delivering the DOM to your service.
>
>-- dims
>
>On Tue, 27 Jul 2004 15:03:20 +0200, Jean-Francois Denise - Sun
>Microsystems <je...@sun.com> wrote:
>  
>
>>I found a problem when accessing header.
>>
>>Context : webservices exposed dynamicaly (WSDL and implementation).
>>
>>In order to define which service is in the scope of a received request,
>>I need to access an Header.
>>
>>I access the header when Axis calls my own instance of
>>EngineConfiguration.getService(QName name).
>>
>>I use Message.getSOAPEnvelope().getHeaderByName(...) I noticed that
>>calling getSOAPEnvelope launches the full message deserialization. The
>>body is also deserialized.
>>
>>In case of WRAPPED/LITERAL this is a problem. The metadata (mainly types
>>of the service operations) used to create the service ServiceDesc
>>are not known when this deserialization occurs. Axis is deserializing
>>the literal values in "best effort" (String for simple types, ...)
>>
>>I perhaps access the header in the wrong place. This could sound strange
>>but I need to access the header in order to findout what is the service.
>>
>>I found a way to do it but it smells the hack... I create a new Message
>>from the received one. Call getSOAPEnvelope() on the newly created one.
>>The deserialization is done twice...
>>
>> Message msg = msgContext.getRequestMessage();
>> Message msg2 = new Message(msg.getSOAPPartAsString());
>> SOAPEnvelope env = msg2.getSOAPEnvelope();
>>
>>Regards.
>>
>>--
>>----------------------------------------------------------------------
>>Jean-Francois Denise            Sun Microsystems
>>Sun ONE/Java Web Services
>>email: jfd@sun.com
>>Internal home page : http://icncweb.france/~jfdenise
>>-------------------------------------------------------------------
>>
>>
>>    
>>
>
>
>  
>


-- 
----------------------------------------------------------------------
Jean-Francois Denise            Sun Microsystems
Sun ONE/Java Web Services
email: jfd@sun.com 
Internal home page : http://icncweb.france/~jfdenise
-------------------------------------------------------------------


Re: Deserialization of received message question

Posted by Jean-Francois Denise - Sun Microsystems <je...@sun.com>.
Today my dynamic provider extends RPCProvider and overrides 
processMessage. It can generate WSDL for interfaces of running JMX 
MBeans as well as routing requests to MBean instances.

Looking at MsgProvider, I noticed that the SOAPEnvelope is a 
processMessage parameter.
It seems to me that, when processMessage is called, the message has 
already been deserialized?
If it is the case, I will have the same problem. I have the feeling that 
I have something wrong here.



Davanum Srinivas wrote:

>This is definitely a hack, i don't recommend using it this way. Do you
>want to experiment a bit with MsgProvider? It's designed specifically
>for delivering the DOM to your service.
>
>-- dims
>
>On Tue, 27 Jul 2004 15:03:20 +0200, Jean-Francois Denise - Sun
>Microsystems <je...@sun.com> wrote:
>  
>
>>I found a problem when accessing header.
>>
>>Context : webservices exposed dynamicaly (WSDL and implementation).
>>
>>In order to define which service is in the scope of a received request,
>>I need to access an Header.
>>
>>I access the header when Axis calls my own instance of
>>EngineConfiguration.getService(QName name).
>>
>>I use Message.getSOAPEnvelope().getHeaderByName(...) I noticed that
>>calling getSOAPEnvelope launches the full message deserialization. The
>>body is also deserialized.
>>
>>In case of WRAPPED/LITERAL this is a problem. The metadata (mainly types
>>of the service operations) used to create the service ServiceDesc
>>are not known when this deserialization occurs. Axis is deserializing
>>the literal values in "best effort" (String for simple types, ...)
>>
>>I perhaps access the header in the wrong place. This could sound strange
>>but I need to access the header in order to findout what is the service.
>>
>>I found a way to do it but it smells the hack... I create a new Message
>>from the received one. Call getSOAPEnvelope() on the newly created one.
>>The deserialization is done twice...
>>
>> Message msg = msgContext.getRequestMessage();
>> Message msg2 = new Message(msg.getSOAPPartAsString());
>> SOAPEnvelope env = msg2.getSOAPEnvelope();
>>
>>Regards.
>>
>>--
>>----------------------------------------------------------------------
>>Jean-Francois Denise            Sun Microsystems
>>Sun ONE/Java Web Services
>>email: jfd@sun.com
>>Internal home page : http://icncweb.france/~jfdenise
>>-------------------------------------------------------------------
>>
>>
>>    
>>
>
>
>  
>


-- 
----------------------------------------------------------------------
Jean-Francois Denise            Sun Microsystems
Sun ONE/Java Web Services
email: jfd@sun.com 
Internal home page : http://icncweb.france/~jfdenise
-------------------------------------------------------------------


Re: Deserialization of received message question

Posted by Davanum Srinivas <da...@gmail.com>.
This is definitely a hack, i don't recommend using it this way. Do you
want to experiment a bit with MsgProvider? It's designed specifically
for delivering the DOM to your service.

-- dims

On Tue, 27 Jul 2004 15:03:20 +0200, Jean-Francois Denise - Sun
Microsystems <je...@sun.com> wrote:
> I found a problem when accessing header.
> 
> Context : webservices exposed dynamicaly (WSDL and implementation).
> 
> In order to define which service is in the scope of a received request,
> I need to access an Header.
> 
> I access the header when Axis calls my own instance of
> EngineConfiguration.getService(QName name).
> 
> I use Message.getSOAPEnvelope().getHeaderByName(...) I noticed that
> calling getSOAPEnvelope launches the full message deserialization. The
> body is also deserialized.
> 
> In case of WRAPPED/LITERAL this is a problem. The metadata (mainly types
> of the service operations) used to create the service ServiceDesc
> are not known when this deserialization occurs. Axis is deserializing
> the literal values in "best effort" (String for simple types, ...)
> 
> I perhaps access the header in the wrong place. This could sound strange
> but I need to access the header in order to findout what is the service.
> 
> I found a way to do it but it smells the hack... I create a new Message
> from the received one. Call getSOAPEnvelope() on the newly created one.
> The deserialization is done twice...
> 
>  Message msg = msgContext.getRequestMessage();
>  Message msg2 = new Message(msg.getSOAPPartAsString());
>  SOAPEnvelope env = msg2.getSOAPEnvelope();
> 
> Regards.
> 
> --
> ----------------------------------------------------------------------
> Jean-Francois Denise            Sun Microsystems
> Sun ONE/Java Web Services
> email: jfd@sun.com
> Internal home page : http://icncweb.france/~jfdenise
> -------------------------------------------------------------------
> 
> 


-- 
Davanum Srinivas - http://webservices.apache.org/~dims/