Way ahead of you. :) Apparently Chris missed this API in SOAPEnvelope:
SOAPHeaderBlock newHeader = envelope.addHeader(namespace, localPart);
In general a big +1 to adding convenience methods to do stuff that
developers actually want to do.
On a related note, I think the fact that we actually have a SOAPHeader
class is kind of ridiculous (we can thank SAAJ for that I guess). From
the user POV there should be just an Envelope which has N "body
elements" (N usually == 1) and N "SOAPHeaderBlock"s (which should really
be called "SOAPHeader"s). There's no real need, IMO, to access the
actual <soap:Body> and <soap:Header> element unless you want to put
namespace declarations on them.
--Glen
Tom Jordahl wrote:
Sure seems like this is a good place for a setHeader() convenience
method!
Let not make the AXIOM/Axis2 API hard to use just for purity sake....
--
Tom Jordahl
-----Original Message-----
From: Chris Lintz [mailto:[EMAIL PROTECTED]
Sent: Thursday, October 13, 2005 5:11 PM
To: axis-dev@ws.apache.org; [EMAIL PROTECTED]
Subject: RE: [Axis2] How to set SOAP Header ?
Thanks for the info. That was close to working for me, but it appears
that way creates just an envelope wihtout the body (atleast errors
related to that were created). Here is what I did to create header
elements that finally worked:
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns1 =
factory.createOMNamespace("http://mynamespace","");
OMElement clientKeyElement =
factory.createOMElement("clientKey",ns1);
clientKeyElement.setText( CLIENT_KEY );
env.getHeader().addChild( clientKeyElement );
-----Original Message-----
From: Eran Chinthaka [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 12, 2005 7:10 PM
To: axis-dev@ws.apache.org
Subject: Re: [Axis2] How to set SOAP Header ?
Hi "Local-Underground" ,
Axis2 has its "native" xml object model called Axiom. We represent the
SOAP message using that.
Every SOAP element extends from OMElement.
So if you want to set a header the easiest way is like this:
SOAPFactory fac = OMAbstractFactory.getSOAP11Factory(); // or
getSOAP12Factory()
SOAPEnvelope = fac.getDefaultSOAPEnvelope(); // this contains
Envelope, Header and the Body
soap12Envelope.getHeader().addHeaderBlock("Your Header Name",
OMNamespace)
If you want more info on AXIOM, read the OM (AXIOM is also referred to
as OM within Axis2 dev team) tutorial found in Axis2 site, or there will
be couple of other tutorials on the web.
-- Chinthaka
local-underground wrote:
Hi,
I am trying to figure out what has changed in terms of how I can now
set a SOAP Header in Axis2. Does any one know how to do so?
Here is my envelope: env = createEnvelope();
But there is no setHeader(String, String) function. I can get the
header, but its not apparent how to successfully set a header.
thanks for any help
__________________________________
Start your day with Yahoo! - Make it your home page!
http://www.yahoo.com/r/hs