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 tht tht <ax...@yahoo.com> on 2005/06/05 21:23:45 UTC

working with SOAP-Headers?

Hello,

please can someone help me by solving the following
problem: I want to write a client-handler, which must
add two values into a SOAPHeader e.g. "clientID" and
"client-adress". Then, a server-handler must extract
these two values and save them into a DB.

In the ivnoke(messageContext) method of client-handler
I try this:

------------------------------------------------      
 
 SOAPMessage msg =
(SOAPMessageContext)messageContext.getMessage();
 SOAPPart part = msg.getSOAPPart();
 SOAPEnvelope envelope = part.getEnvelope();
 SOAPHeader header = envelope.getHeader();

 SOAPHeaderElement headerElement =
(SOAPHeaderElement)header.addHeaderElement(envelope.createName("clientID"));
      headerElement.setActor("actor_1");
     
headerElement.setNamespaceURI("www.axisaccount.net/tbsg");
      headerElement.setValue("33");
      
      SOAPHeaderElement headerElement2
         =
(SOAPHeaderElement)header.addHeaderElement(envelope.createName("client-adress"));
     
      
      headerElement2.setMustUnderstand(false);
      headerElement2.setActor("actor_2");
     
headerElement2.setNamespaceURI("www.axisaccount.net/tbsg");
      headerElement2.setValue("192.168.11.1");
-------------------------------------------------

the result is the following Header:



    <soapenv: Header>
    <ns1:clientID soapenv:actor="actor_1"
soapenv:mustunderstand="0" xsi:type="soapenc:string"
xmlns="" xmlns:ns1="www.axisaccount.net/tbsg"
xmlns:soapenc="http://shemas.xmlsoap.org/soap/encoding/">33</nsl:clientID>

    <ns2:client-adress soapenv:actor="actor_""
soapenv:mustunderstand="0" xsi:type="soapenc:string"
xmlns="" xmlns:ns2="www.axisaccount.net/tbsg"
xmlns:soapenc="http://shemas.xmlsoap.org/soap/encoding/">192.168.11.1</nsl:client-adress>
    </soapenv: Header>
-----------------------------------------------


Please tell me, how I can get these two
values(clientID and client-adress) with the
server-handler.

many thanks in advance,
ivana


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: working with SOAP-Headers?

Posted by tht tht <ax...@yahoo.com>.
Hi, 

> sorry i couldnt help much,
> nate
Nevertheless thank you for your suggestion :))

Ivana




		
__________________________________ 
Discover Yahoo! 
Stay in touch with email, IM, photo sharing and more. Check it out! 
http://discover.yahoo.com/stayintouch.html

Re: working with SOAP-Headers?

Posted by "Nathaniel A. Johnson" <na...@indiana.edu>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

tht tht wrote:
> Hello Nate, 
> 
> thanks for your prompt reply, in the
> invoke(msgContext) method of server-handler I have
> tried this:
> 
> ----------------------------------------------
>       Message msg = msgContext.getRequestMessage(); 
>           SOAPEnvelope env =  msg.getSOAPEnvelope();
> 
>           SOAPHeaderElement header =
> env.getHeaderByName("www.axisaccount.net/tbsg","client-adress");
>           
>           String s = header.getValue();
> ----------------------------------------------
> 
> But, I get a java.lang.NullPointerException.

well, i don't do much with soap, so i don't really have any advice... i
guess i'd try something like this:

MessageContext msgContext = MessageContext.getCurrentContext();
SOAPHeader header = msgContext.getMessage().getSOAPHeader();

and go from there... i usually just debug into the code and browse
around with eclipse.... either that or just map everything i want to
used to java objects and let the tools do the serialization for me.

sorry i couldnt help much,
nate

> 
> Thanks again
> Ivana
> 
> 
> 		
> __________________________________ 
> Discover Yahoo! 
> Stay in touch with email, IM, photo sharing and more. Check it out! 
> http://discover.yahoo.com/stayintouch.html
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCo15vgj8ksIjnb2wRAm8kAKCBoqm6qWzb5teQrs8OVut77BV9vwCeJwCb
Sf29iuDeuYuLFDJ/PGaOSYk=
=AhqF
-----END PGP SIGNATURE-----

Re: working with SOAP-Headers?

Posted by tht tht <ax...@yahoo.com>.
Hello Nate, 

thanks for your prompt reply, in the
invoke(msgContext) method of server-handler I have
tried this:

----------------------------------------------
      Message msg = msgContext.getRequestMessage(); 
          SOAPEnvelope env =  msg.getSOAPEnvelope();

          SOAPHeaderElement header =
env.getHeaderByName("www.axisaccount.net/tbsg","client-adress");
          
          String s = header.getValue();
----------------------------------------------

But, I get a java.lang.NullPointerException.

Thanks again
Ivana


		
__________________________________ 
Discover Yahoo! 
Stay in touch with email, IM, photo sharing and more. Check it out! 
http://discover.yahoo.com/stayintouch.html

Re: working with SOAP-Headers?

Posted by "Nathaniel A. Johnson" <na...@indiana.edu>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ivana,

You can get the entire soap message from the MessageContext object:

MessageContext msgContext = MessageContext.getCurrentContext();

Then you can dig through it, or use the javadocs to figure out how to
get the headers (I don't remember right off hand), and find everything
in the soap request.

Nate


tht tht wrote:
> Hello,
> 
> please can someone help me by solving the following
> problem: I want to write a client-handler, which must
> add two values into a SOAPHeader e.g. "clientID" and
> "client-adress". Then, a server-handler must extract
> these two values and save them into a DB.
> 
> In the ivnoke(messageContext) method of client-handler
> I try this:
> 
> ------------------------------------------------      
>  
>  SOAPMessage msg =
> (SOAPMessageContext)messageContext.getMessage();
>  SOAPPart part = msg.getSOAPPart();
>  SOAPEnvelope envelope = part.getEnvelope();
>  SOAPHeader header = envelope.getHeader();
> 
>  SOAPHeaderElement headerElement =
> (SOAPHeaderElement)header.addHeaderElement(envelope.createName("clientID"));
>       headerElement.setActor("actor_1");
>      
> headerElement.setNamespaceURI("www.axisaccount.net/tbsg");
>       headerElement.setValue("33");
>       
>       SOAPHeaderElement headerElement2
>          =
> (SOAPHeaderElement)header.addHeaderElement(envelope.createName("client-adress"));
>      
>       
>       headerElement2.setMustUnderstand(false);
>       headerElement2.setActor("actor_2");
>      
> headerElement2.setNamespaceURI("www.axisaccount.net/tbsg");
>       headerElement2.setValue("192.168.11.1");
> -------------------------------------------------
> 
> the result is the following Header:
> 
> 
> 
>     <soapenv: Header>
>     <ns1:clientID soapenv:actor="actor_1"
> soapenv:mustunderstand="0" xsi:type="soapenc:string"
> xmlns="" xmlns:ns1="www.axisaccount.net/tbsg"
> xmlns:soapenc="http://shemas.xmlsoap.org/soap/encoding/">33</nsl:clientID>
> 
>     <ns2:client-adress soapenv:actor="actor_""
> soapenv:mustunderstand="0" xsi:type="soapenc:string"
> xmlns="" xmlns:ns2="www.axisaccount.net/tbsg"
> xmlns:soapenc="http://shemas.xmlsoap.org/soap/encoding/">192.168.11.1</nsl:client-adress>
>     </soapenv: Header>
> -----------------------------------------------
> 
> 
> Please tell me, how I can get these two
> values(clientID and client-adress) with the
> server-handler.
> 
> many thanks in advance,
> ivana
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (MingW32)

iD8DBQFCo1I7gj8ksIjnb2wRAq2ZAJ91AF+qZ7/+LHaRTxVwgz0n2mrbywCdGio/
jDfeGcOvBmeZUlZWY+4OwA4=
=4Mes
-----END PGP SIGNATURE-----