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 Dhanush Gopinath <dh...@mahindrabt.com> on 2004/06/01 06:43:26 UTC
Re: Populating SOAPHeader and SOAPBody.
Hi There
At the client side u can instatiate a Stub Object from the org.apache.axis.client and use
a method setHeader() to set the Header of an out going SOAP Message, I mean request Message.
At the server side do this :
MessageContext msgContext = MessageContext.getCurrentContext();
Message reqMsg = msgContext.getRequestMessage();
// Gets the SOAPNevelope for the Request Message
SOAPEnvelope soapEnv= reqMsg.getSOAPEnvelope();
// Gets the SOAPHeader for the Request Message
SOAPHeader soapHead= (org.apache.axis.message.SOAPHeader)soapEnv.getHeader();
// Gets all the SOAPHeaderElements into an Iterator
Iterator itrElements= soapHead.getChildElements();
Iterate through this iterator to extract each Child element of the Header.
Hope this helps.
Cheers
Dhanush
----- Original Message -----
From: Ilari Kontinen
To: axis-user@ws.apache.org
Sent: Tuesday, June 01, 2004 12:02 AM
Subject: Populating SOAPHeader and SOAPBody.
Hello,
I would like to have some advices / comments about populating SOAPHeader
and SOAPBody of a SOAPEnvelope (org.apache.axis.message.*).
I have a web service that receives a SOAPEnvelope, and saves its
SOAPHeader and SOAPBody parts to a database (as String). At a later
time, when another SOAP-request comes in, the web service gets the
String-values from database, and populates the SOAPEnvelope with them.
I am wondering, what is the easiest/best/right way to populate the
SOAPHeader and SOAPBody of the SOAPEnvelope when they are already
represented as Strings?
For example, if the SOAPHeader-part is saved as following in the
database, how should I insert it to a SOAPEnvelope?
<SOAP-ENV:Header>
<ar:MessageHeader SOAP-ENV:mustUnderstand="1">
<ar:From>
<ar:PartyId>ID 1</ar:PartyId>
<ar:Role>requester</ar:Role>
</ar:From>
<ar:To>
<ar:PartyId>ID 1</ar:PartyId>
<ar:Role>responder</ar:Role>
</ar:To>
</ar:MessageHeader SOAP-ENV:mustUnderstand="1">
</SOAP-ENV:Header>
~ Ilari Kontinen
*********************************************************
Disclaimer:
This message (including any attachments) contains
confidential information intended for a specific
individual and purpose, and is protected by law.
If you are not the intended recipient, you should
delete this message and are hereby notified that
any disclosure, copying, or distribution of this
message, or the taking of any action based on it,
is strictly prohibited.
*********************************************************
Visit us at http://www.mahindrabt.com
Re: Populating SOAPHeader and SOAPBody.
Posted by Dhanush Gopinath <dh...@mahindrabt.com>.
In that case u may need to parse the string and set the SOAPHeader of the SOAPEnvelope according to the namespace and values
----- Original Message -----
From: Ilari Kontinen
To: axis-user@ws.apache.org
Sent: Tuesday, June 01, 2004 12:05 PM
Subject: Re: Populating SOAPHeader and SOAPBody.
Dhanush Gopinath wrote:
> Hi There
>
> At the client side u can instatiate a Stub Object from the
> org.apache.axis.client and use
> a method setHeader() to set the Header of an out going SOAP Message,
> I mean request Message.
>
> At the server side do this :
>
> * MessageContext msgContext = MessageContext.getCurrentContext();
> Message reqMsg = msgContext.getRequestMessage();
>
> // Gets the SOAPNevelope for the Request Message
> SOAPEnvelope soapEnv= reqMsg.getSOAPEnvelope();
> // Gets the SOAPHeader for the Request Message
> SOAPHeader soapHead=
> (org.apache.axis.message.SOAPHeader)soapEnv.getHeader();
> // Gets all the SOAPHeaderElements into an Iterator
> Iterator itrElements= soapHead.getChildElements();*
>
> Iterate through this iterator to extract each Child element of the
> Header.
Yes, I am able to extract the data from an incoming SOAPEnvelope, but I
was wondering what is the easiest/right way to input the data back to
another SOAPEnvelope, when I have the Header and Body parts as Strings
(in a database). I need to do it at the server-side, so the client
methods are not available.
> Hello,
>
> I would like to have some advices / comments about populating
> SOAPHeader
> and SOAPBody of a SOAPEnvelope (org.apache.axis.message.*).
>
> I have a web service that receives a SOAPEnvelope, and saves its
> SOAPHeader and SOAPBody parts to a database (as String). At a later
> time, when another SOAP-request comes in, the web service gets the
> String-values from database, and populates the SOAPEnvelope with them.
>
> I am wondering, what is the easiest/best/right way to populate the
> SOAPHeader and SOAPBody of the SOAPEnvelope when they are already
> represented as Strings?
>
> For example, if the SOAPHeader-part is saved as following in the
> database, how should I insert it to a SOAPEnvelope?
>
> <SOAP-ENV:Header>
> <ar:MessageHeader SOAP-ENV:mustUnderstand="1">
> <ar:From>
> <ar:PartyId>ID 1</ar:PartyId>
> <ar:Role>requester</ar:Role>
> </ar:From>
> <ar:To>
> <ar:PartyId>ID 1</ar:PartyId>
> <ar:Role>responder</ar:Role>
> </ar:To>
> </ar:MessageHeader SOAP-ENV:mustUnderstand="1">
> </SOAP-ENV:Header>
>
> ~ Ilari Kontinen
>
*********************************************************
Disclaimer:
This message (including any attachments) contains
confidential information intended for a specific
individual and purpose, and is protected by law.
If you are not the intended recipient, you should
delete this message and are hereby notified that
any disclosure, copying, or distribution of this
message, or the taking of any action based on it,
is strictly prohibited.
*********************************************************
Visit us at http://www.mahindrabt.com
Re: Populating SOAPHeader and SOAPBody.
Posted by Ilari Kontinen <il...@hut.fi>.
Dhanush Gopinath wrote:
> Hi There
>
> At the client side u can instatiate a Stub Object from the
> org.apache.axis.client and use
> a method setHeader() to set the Header of an out going SOAP Message,
> I mean request Message.
>
> At the server side do this :
>
> * MessageContext msgContext = MessageContext.getCurrentContext();
> Message reqMsg = msgContext.getRequestMessage();
>
> // Gets the SOAPNevelope for the Request Message
> SOAPEnvelope soapEnv= reqMsg.getSOAPEnvelope();
> // Gets the SOAPHeader for the Request Message
> SOAPHeader soapHead=
> (org.apache.axis.message.SOAPHeader)soapEnv.getHeader();
> // Gets all the SOAPHeaderElements into an Iterator
> Iterator itrElements= soapHead.getChildElements();*
>
> Iterate through this iterator to extract each Child element of the
> Header.
Yes, I am able to extract the data from an incoming SOAPEnvelope, but I
was wondering what is the easiest/right way to input the data back to
another SOAPEnvelope, when I have the Header and Body parts as Strings
(in a database). I need to do it at the server-side, so the client
methods are not available.
> Hello,
>
> I would like to have some advices / comments about populating
> SOAPHeader
> and SOAPBody of a SOAPEnvelope (org.apache.axis.message.*).
>
> I have a web service that receives a SOAPEnvelope, and saves its
> SOAPHeader and SOAPBody parts to a database (as String). At a later
> time, when another SOAP-request comes in, the web service gets the
> String-values from database, and populates the SOAPEnvelope with them.
>
> I am wondering, what is the easiest/best/right way to populate the
> SOAPHeader and SOAPBody of the SOAPEnvelope when they are already
> represented as Strings?
>
> For example, if the SOAPHeader-part is saved as following in the
> database, how should I insert it to a SOAPEnvelope?
>
> <SOAP-ENV:Header>
> <ar:MessageHeader SOAP-ENV:mustUnderstand="1">
> <ar:From>
> <ar:PartyId>ID 1</ar:PartyId>
> <ar:Role>requester</ar:Role>
> </ar:From>
> <ar:To>
> <ar:PartyId>ID 1</ar:PartyId>
> <ar:Role>responder</ar:Role>
> </ar:To>
> </ar:MessageHeader SOAP-ENV:mustUnderstand="1">
> </SOAP-ENV:Header>
>
> ~ Ilari Kontinen
>