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 Brennan Spies <br...@sbcglobal.net> on 2006/12/01 02:18:02 UTC

RE: how to get soap header from stub in axis2

The SOAPEnvelope (which you create on the client or receive from the
service) has a getHeader() method for getting the SOAPHeader axiom class
that has the appropriate methods. The ServiceClient (class member in the
Stub) also has helper methods for adding SOAP headers.

 

  _____  

From: hoy hoy [mailto:liveforhim@gmail.com] 
Sent: Thursday, November 30, 2006 1:55 PM
To: axis-user@ws.apache.org
Subject: how to get soap header from stub in axis2

 

Hi all,

I'm using Axis 2 1.1 and have a stub that was generated from a WSDL.  The
soap call that I'm making returns SOAP headers, namely session information.
How can I retrieve those SOAP headers from my stub?  What methods or helper
classes do I need to use? 

Thanks,
Hoy


RE: how to get soap header from stub in axis2

Posted by Brennan Spies <br...@sbcglobal.net>.
No, there's nothing sacred about generated code.ideally you're only supposed
to implement the Skeleton class, but if you need to do things with the SOAP
message itself, you'll have to do it in the Stub.

 

  _____  

From: hoy hoy [mailto:liveforhim@gmail.com] 
Sent: Friday, December 01, 2006 5:04 PM
To: axis-user@ws.apache.org; brennanspies@sbcglobal.net
Subject: Re: how to get soap header from stub in axis2

 

Yes I saw that in the generated Stub.  But is there a way to extract the
SOAP header without modifying the generated stub?  

My understanding was the stubs are not supposed to be modified?  I was
hoping to extract the header by using the generated stub methods.  I suppose
this will only be exposed if the soap-headers are explicitly declared in the
WSDL (which they are not in my case). 

-Hoy



On 12/1/06, Brennan Spies <br...@sbcglobal.net> wrote:

Assuming you are talking about the return envelope (from the service), you
should see something like

 

                  org.apache.axis2.context.MessageContext
_returnMessageContext = _operationClient

 
.getMessageContext(org.apache.axis2.wsdl.WSDLConstants.
MESSAGE_LABEL_IN_VALUE); 

                  org.apache.axiom.soap.SOAPEnvelope _returnEnv =
_returnMessageContext

                              .getEnvelope(); 

 

In your stub's invocation method. You can use a _returnEnv.getHeader() call
to access the header.

 

  _____  

From: hoy hoy [mailto:liveforhim@gmail.com] 
Sent: Friday, December 01, 2006 2:40 PM
To: axis-user@ws.apache.org; brennanspies@sbcglobal.net
Subject: Re: how to get soap header from stub in axis2

 

I know how to add headers, via:

stub._getServiceClient().addStringHeader(...)

however, after the call is made;

stub.MyMethodToInvoke(...)

I want to view the soap headers that are returned.  Using ethereal (network
sniffer) I can see the headers, but they are not exposed on the stub class.
There are no, stub.getHeader(...) methods that I can use, unless I need to
do something fancier?

How do I get the SOAPEnvelope from a Stub?  Eseentially, the stub is all I'm
working with or do I need to look elsewhere?

Thanks so much for your help Brennan! 

Hoy

On 11/30/06, Brennan Spies <br...@sbcglobal.net> wrote:

The SOAPEnvelope (which you create on the client or receive from the
service) has a getHeader() method for getting the SOAPHeader axiom class
that has the appropriate methods. The ServiceClient (class member in the
Stub) also has helper methods for adding SOAP headers.

 

  _____  

From: hoy hoy [mailto: liveforhim@gmail.com] 
Sent: Thursday, November 30, 2006 1:55 PM
To: axis-user@ws.apache.org
Subject: how to get soap header from stub in axis2

 

Hi all,

I'm using Axis 2 1.1 and have a stub that was generated from a WSDL.  The
soap call that I'm making returns SOAP headers, namely session information.
How can I retrieve those SOAP headers from my stub?  What methods or helper
classes do I need to use? 

Thanks,
Hoy

 

 


Re: how to get soap header from stub in axis2

Posted by hoy hoy <li...@gmail.com>.
Yes I saw that in the generated Stub.  But is there a way to extract the
SOAP header without modifying the generated stub?

My understanding was the stubs are not supposed to be modified?  I was
hoping to extract the header by using the generated stub methods.  I suppose
this will only be exposed if the soap-headers are explicitly declared in the
WSDL (which they are not in my case).

-Hoy


On 12/1/06, Brennan Spies <br...@sbcglobal.net> wrote:
>
>  Assuming you are talking about the return envelope (from the service),
> you should see something like
>
>
>
>                   org.apache.axis2.context.MessageContext_returnMessageContext = _operationClient
>
>                               .getMessageContext(
> org.apache.axis2.wsdl.WSDLConstants.*MESSAGE_LABEL_IN_VALUE*);
>
>                   org.apache.axiom.soap.SOAPEnvelope _returnEnv =
> _returnMessageContext
>
>                               .getEnvelope();
>
>
>
> In your stub's invocation method. You can use a _returnEnv.getHeader()
> call to access the header.
>
>
>  ------------------------------
>
> *From:* hoy hoy [mailto:liveforhim@gmail.com]
> *Sent:* Friday, December 01, 2006 2:40 PM
> *To:* axis-user@ws.apache.org; brennanspies@sbcglobal.net
> *Subject:* Re: how to get soap header from stub in axis2
>
>
>
> I know how to add headers, via:
>
> stub._getServiceClient().addStringHeader(...)
>
> however, after the call is made;
>
> stub.MyMethodToInvoke(...)
>
> I want to view the soap headers that are returned.  Using ethereal
> (network sniffer) I can see the headers, but they are not exposed on the
> stub class.  There are no, stub.getHeader(...) methods that I can use,
> unless I need to do something fancier?
>
> How do I get the SOAPEnvelope from a Stub?  Eseentially, the stub is all
> I'm working with or do I need to look elsewhere?
>
> Thanks so much for your help Brennan!
>
> Hoy
>
>  On 11/30/06, *Brennan Spies* <br...@sbcglobal.net> wrote:
>
> The SOAPEnvelope (which you create on the client or receive from the
> service) has a getHeader() method for getting the SOAPHeader axiom class
> that has the appropriate methods. The ServiceClient (class member in the
> Stub) also has helper methods for adding SOAP headers.
>
>
>  ------------------------------
>
> *From:* hoy hoy [mailto:liveforhim@gmail.com]
> *Sent:* Thursday, November 30, 2006 1:55 PM
> *To:* axis-user@ws.apache.org
> *Subject:* how to get soap header from stub in axis2
>
>
>
> Hi all,
>
> I'm using Axis 2 1.1 and have a stub that was generated from a WSDL.  The
> soap call that I'm making returns SOAP headers, namely session information.
> How can I retrieve those SOAP headers from my stub?  What methods or helper
> classes do I need to use?
>
> Thanks,
> Hoy
>
>
>

Re: how to get soap header from stub in axis2

Posted by Sanjiva Weerawarana <sa...@opensource.lk>.
A stub uses an operation client inside each method. The life of the
operation client is thus equal to the life of that method call. An
option would be to add a method to ServiceClient() to get the "last"
used operation client. Then one could get the last operation client,
get the appropriate message context from that and grab whatever info
needed.

We could implement this fairly trivially by making operationClient an
instance variable of ServiceClient and updating that whenever a new one
is created. ServiceClient is already declared to be not thread safe so
this should work ok (I think).

Sanjiva.

On Mon, 2006-12-04 at 14:20 -0500, Deepal Jayasinghe wrote:
> Well in the current code base we do not have a way to get either
> operation client or message context from the stub. I think we can
> provide a way to access the current message context in the stub and from
> that SOAP envelop and any other properties.
> 
> So please create a JIRA so that we will not forget the issue.
> 
> Thanks
> Deepal
> 
> Shaoguang Cong wrote:
> 
> > Deepal Jayasinghe has a paper mentioned that.
> > http://www-128.ibm.com/developerworks/webservices/library/ws-soa-axis2-1/ 
> > "With service clients you can only access SOAP body or the pay load.
> > Of course you can add SOAP headers but you do not have a way to
> > retrieve SOAP header from service client. For that you will need to
> > use an operation client."
> > The problem is that the generated stub doesn't give a way to access
> > the operation client.
> > So from the client stub, one seems cannot get access to the operation
> > client, messageContext or SOAPHeader. Anybody knows if there's a way
> > to get such info from client handler?
> >  
> > Shaoguang
> >
> > */Jatinder Kaur <ja...@gmail.com>/* wrote:
> >
> >     I am also looking to do the same -- basically, the Stub is just
> >     returning the SOAP Body. I would also like to retrieve SOAP
> >     Headers without having to modify the stub (generated) code.
> >      
> >     Is there any way to do this?
> >      
> >     Thanks,
> >     Jatinder
> >
> >      
> >     On 12/1/06, *hoy hoy* <liveforhim@gmail.com
> >     <ma...@gmail.com>> wrote:
> >
> >         I know how to add headers, via:
> >
> >         stub._getServiceClient().addStringHeader(...)
> >
> >         however, after the call is made;
> >
> >         stub.MyMethodToInvoke(...)
> >
> >         I want to view the soap headers that are returned.  Using
> >         ethereal (network sniffer) I can see the headers, but they are
> >         not exposed on the stub class.  There are no, stub.getHeader
> >         (...) methods that I can use, unless I need to do something
> >         fancier?
> >
> >         How do I get the SOAPEnvelope from a Stub?  Eseentially, the
> >         stub is all I'm working with or do I need to look elsewhere?
> >
> >         Thanks so much for your help Brennan!
> >
> >         Hoy
> >
> >
> >         On 11/30/06, *Brennan Spies* <brennanspies@sbcglobal.net
> >         <ma...@sbcglobal.net>> wrote:
> >
> >             The SOAPEnvelope (which you create on the client or
> >             receive from the service) has a getHeader() method for
> >             getting the SOAPHeader axiom class that has the
> >             appropriate methods. The ServiceClient (class member in
> >             the Stub) also has helper methods for adding SOAP headers.
> >              
> >             ------------------------------------------------------------------------
> >             *From:* hoy hoy [mailto: liveforhim@gmail.com
> >             <ma...@gmail.com>]
> >             *Sent:* Thursday, November 30, 2006 1:55 PM
> >             *To:* axis-user@ws.apache.org <ma...@ws.apache.org>
> >             *Subject:* how to get soap header from stub in axis2
> >              
> >             Hi all,
> >
> >             I'm using Axis 2 1.1 and have a stub that was generated
> >             from a WSDL.  The soap call that I'm making returns SOAP
> >             headers, namely session information.  How can I retrieve
> >             those SOAP headers from my stub?  What methods or helper
> >             classes do I need to use?
> >
> >             Thanks,
> >             Hoy
> >
> >
> >
> >
> > ------------------------------------------------------------------------
> > Everyone is raving about the all-new Yahoo! Mail beta.
> > <http://us.rd.yahoo.com/evt=45083/*http://advision.webevents.yahoo.com/mailbeta>
> 
> 
> 
-- 
Sanjiva Weerawarana, Ph.D.
Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
Director; Open Source Initiative; http://www.opensource.org/
Member; Apache Software Foundation; http://www.apache.org/
Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: how to get soap header from stub in axis2

Posted by Deepal Jayasinghe <de...@opensource.lk>.
Well in the current code base we do not have a way to get either
operation client or message context from the stub. I think we can
provide a way to access the current message context in the stub and from
that SOAP envelop and any other properties.

So please create a JIRA so that we will not forget the issue.

Thanks
Deepal

Shaoguang Cong wrote:

> Deepal Jayasinghe has a paper mentioned that.
> http://www-128.ibm.com/developerworks/webservices/library/ws-soa-axis2-1/ 
> "With service clients you can only access SOAP body or the pay load.
> Of course you can add SOAP headers but you do not have a way to
> retrieve SOAP header from service client. For that you will need to
> use an operation client."
> The problem is that the generated stub doesn't give a way to access
> the operation client.
> So from the client stub, one seems cannot get access to the operation
> client, messageContext or SOAPHeader. Anybody knows if there's a way
> to get such info from client handler?
>  
> Shaoguang
>
> */Jatinder Kaur <ja...@gmail.com>/* wrote:
>
>     I am also looking to do the same -- basically, the Stub is just
>     returning the SOAP Body. I would also like to retrieve SOAP
>     Headers without having to modify the stub (generated) code.
>      
>     Is there any way to do this?
>      
>     Thanks,
>     Jatinder
>
>      
>     On 12/1/06, *hoy hoy* <liveforhim@gmail.com
>     <ma...@gmail.com>> wrote:
>
>         I know how to add headers, via:
>
>         stub._getServiceClient().addStringHeader(...)
>
>         however, after the call is made;
>
>         stub.MyMethodToInvoke(...)
>
>         I want to view the soap headers that are returned.  Using
>         ethereal (network sniffer) I can see the headers, but they are
>         not exposed on the stub class.  There are no, stub.getHeader
>         (...) methods that I can use, unless I need to do something
>         fancier?
>
>         How do I get the SOAPEnvelope from a Stub?  Eseentially, the
>         stub is all I'm working with or do I need to look elsewhere?
>
>         Thanks so much for your help Brennan!
>
>         Hoy
>
>
>         On 11/30/06, *Brennan Spies* <brennanspies@sbcglobal.net
>         <ma...@sbcglobal.net>> wrote:
>
>             The SOAPEnvelope (which you create on the client or
>             receive from the service) has a getHeader() method for
>             getting the SOAPHeader axiom class that has the
>             appropriate methods. The ServiceClient (class member in
>             the Stub) also has helper methods for adding SOAP headers.
>              
>             ------------------------------------------------------------------------
>             *From:* hoy hoy [mailto: liveforhim@gmail.com
>             <ma...@gmail.com>]
>             *Sent:* Thursday, November 30, 2006 1:55 PM
>             *To:* axis-user@ws.apache.org <ma...@ws.apache.org>
>             *Subject:* how to get soap header from stub in axis2
>              
>             Hi all,
>
>             I'm using Axis 2 1.1 and have a stub that was generated
>             from a WSDL.  The soap call that I'm making returns SOAP
>             headers, namely session information.  How can I retrieve
>             those SOAP headers from my stub?  What methods or helper
>             classes do I need to use?
>
>             Thanks,
>             Hoy
>
>
>
>
> ------------------------------------------------------------------------
> Everyone is raving about the all-new Yahoo! Mail beta.
> <http://us.rd.yahoo.com/evt=45083/*http://advision.webevents.yahoo.com/mailbeta>



-- 
Thanks,
Deepal
................................................................
"The highest tower is built one brick at a time"



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: how to get soap header from stub in axis2

Posted by Shaoguang Cong <sc...@yahoo.com>.
Deepal Jayasinghe has a paper mentioned that.
  http://www-128.ibm.com/developerworks/webservices/library/ws-soa-axis2-1/ 
  "With service clients you can only access SOAP body or the pay load. Of course you can add SOAP headers but you do not have a way to retrieve SOAP header from service client. For that you will need to use an operation client." 

  The problem is that the generated stub doesn't give a way to access the operation client.
  So from the client stub, one seems cannot get access to the operation client, messageContext or SOAPHeader. Anybody knows if there's a way to get such info from client handler?
   
  Shaoguang
  
Jatinder Kaur <ja...@gmail.com> wrote:
    I am also looking to do the same -- basically, the Stub is just returning the SOAP Body. I would also like to retrieve SOAP Headers without having to modify the stub (generated) code.
   
  Is there any way to do this?
   
  Thanks,
  Jatinder

 
  On 12/1/06, hoy hoy <li...@gmail.com> wrote:   I know how to add headers, via:

stub._getServiceClient().addStringHeader(...)

however, after the call is made; 

stub.MyMethodToInvoke(...)

I want to view the soap headers that are returned.  Using ethereal (network sniffer) I can see the headers, but they are not exposed on the stub class.  There are no, stub.getHeader (...) methods that I can use, unless I need to do something fancier?

How do I get the SOAPEnvelope from a Stub?  Eseentially, the stub is all I'm working with or do I need to look elsewhere?

Thanks so much for your help Brennan! 

Hoy


  On 11/30/06, Brennan Spies <brennanspies@sbcglobal.net > wrote:         The SOAPEnvelope (which you create on the client or receive from the service) has a getHeader() method for getting the SOAPHeader axiom class that has the appropriate methods. The ServiceClient (class member in the Stub) also has helper methods for adding SOAP headers. 
   
      
---------------------------------
  
  From: hoy hoy [mailto: liveforhim@gmail.com] 
Sent: Thursday, November 30, 2006 1:55 PM 
To: axis-user@ws.apache.org
Subject: how to get soap header from stub in axis2

     
  Hi all,

I'm using Axis 2 1.1 and have a stub that was generated from a WSDL.  The soap call that I'm making returns SOAP headers, namely session information.  How can I retrieve those SOAP headers from my stub?  What methods or helper classes do I need to use? 

Thanks,
Hoy









 
---------------------------------
Everyone is raving about the all-new Yahoo! Mail beta.

Re: how to get soap header from stub in axis2

Posted by Jatinder Kaur <ja...@gmail.com>.
I am also looking to do the same -- basically, the Stub is just returning
the SOAP Body. I would also like to retrieve SOAP Headers without having to
modify the stub (generated) code.

Is there any way to do this?

Thanks,
Jatinder


On 12/1/06, hoy hoy <li...@gmail.com> wrote:
>
> I know how to add headers, via:
>
> stub._getServiceClient().addStringHeader(...)
>
> however, after the call is made;
>
> stub.MyMethodToInvoke(...)
>
> I want to view the soap headers that are returned.  Using ethereal
> (network sniffer) I can see the headers, but they are not exposed on the
> stub class.  There are no, stub.getHeader(...) methods that I can use,
> unless I need to do something fancier?
>
> How do I get the SOAPEnvelope from a Stub?  Eseentially, the stub is all
> I'm working with or do I need to look elsewhere?
>
> Thanks so much for your help Brennan!
>
> Hoy
>
>
> On 11/30/06, Brennan Spies <br...@sbcglobal.net> wrote:
> >
> >  The SOAPEnvelope (which you create on the client or receive from the
> > service) has a getHeader() method for getting the SOAPHeader axiom class
> > that has the appropriate methods. The ServiceClient (class member in the
> > Stub) also has helper methods for adding SOAP headers.
> >
> >
> >  ------------------------------
> >
> > *From:* hoy hoy [mailto:liveforhim@gmail.com]
> > *Sent:* Thursday, November 30, 2006 1:55 PM
> > *To:* axis-user@ws.apache.org
> > *Subject:* how to get soap header from stub in axis2
> >
> >
> >
> > Hi all,
> >
> > I'm using Axis 2 1.1 and have a stub that was generated from a WSDL.
> > The soap call that I'm making returns SOAP headers, namely session
> > information.  How can I retrieve those SOAP headers from my stub?  What
> > methods or helper classes do I need to use?
> >
> > Thanks,
> > Hoy
> >
>
>

RE: how to get soap header from stub in axis2

Posted by Brennan Spies <br...@sbcglobal.net>.
Assuming you are talking about the return envelope (from the service), you
should see something like

 

                  org.apache.axis2.context.MessageContext
_returnMessageContext = _operationClient

 
.getMessageContext(org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALU
E);

                  org.apache.axiom.soap.SOAPEnvelope _returnEnv =
_returnMessageContext

                              .getEnvelope();

 

In your stub's invocation method. You can use a _returnEnv.getHeader() call
to access the header.

 

  _____  

From: hoy hoy [mailto:liveforhim@gmail.com] 
Sent: Friday, December 01, 2006 2:40 PM
To: axis-user@ws.apache.org; brennanspies@sbcglobal.net
Subject: Re: how to get soap header from stub in axis2

 

I know how to add headers, via:

stub._getServiceClient().addStringHeader(...)

however, after the call is made;

stub.MyMethodToInvoke(...)

I want to view the soap headers that are returned.  Using ethereal (network
sniffer) I can see the headers, but they are not exposed on the stub class.
There are no, stub.getHeader(...) methods that I can use, unless I need to
do something fancier?

How do I get the SOAPEnvelope from a Stub?  Eseentially, the stub is all I'm
working with or do I need to look elsewhere?

Thanks so much for your help Brennan! 

Hoy



On 11/30/06, Brennan Spies <br...@sbcglobal.net> wrote:

The SOAPEnvelope (which you create on the client or receive from the
service) has a getHeader() method for getting the SOAPHeader axiom class
that has the appropriate methods. The ServiceClient (class member in the
Stub) also has helper methods for adding SOAP headers.

 

  _____  

From: hoy hoy [mailto:liveforhim@gmail.com] 
Sent: Thursday, November 30, 2006 1:55 PM
To: axis-user@ws.apache.org
Subject: how to get soap header from stub in axis2

 

Hi all,

I'm using Axis 2 1.1 and have a stub that was generated from a WSDL.  The
soap call that I'm making returns SOAP headers, namely session information.
How can I retrieve those SOAP headers from my stub?  What methods or helper
classes do I need to use? 

Thanks,
Hoy

 


Re: how to get soap header from stub in axis2

Posted by hoy hoy <li...@gmail.com>.
I know how to add headers, via:

stub._getServiceClient().addStringHeader(...)

however, after the call is made;

stub.MyMethodToInvoke(...)

I want to view the soap headers that are returned.  Using ethereal (network
sniffer) I can see the headers, but they are not exposed on the stub class.
There are no, stub.getHeader(...) methods that I can use, unless I need to
do something fancier?

How do I get the SOAPEnvelope from a Stub?  Eseentially, the stub is all I'm
working with or do I need to look elsewhere?

Thanks so much for your help Brennan!

Hoy


On 11/30/06, Brennan Spies <br...@sbcglobal.net> wrote:
>
>  The SOAPEnvelope (which you create on the client or receive from the
> service) has a getHeader() method for getting the SOAPHeader axiom class
> that has the appropriate methods. The ServiceClient (class member in the
> Stub) also has helper methods for adding SOAP headers.
>
>
>  ------------------------------
>
> *From:* hoy hoy [mailto:liveforhim@gmail.com]
> *Sent:* Thursday, November 30, 2006 1:55 PM
> *To:* axis-user@ws.apache.org
> *Subject:* how to get soap header from stub in axis2
>
>
>
> Hi all,
>
> I'm using Axis 2 1.1 and have a stub that was generated from a WSDL.  The
> soap call that I'm making returns SOAP headers, namely session information.
> How can I retrieve those SOAP headers from my stub?  What methods or helper
> classes do I need to use?
>
> Thanks,
> Hoy
>