Hi,

 

I have problem to set a Header into a SOAP Message with Apache SOAP 2.2

Here's the code to add a header to my message, but unfortunately, it doesn't seem to work.

When I look at the message by example through TunnelGui, I can't see my header.

Does Apache support the Header blocks or not?

Thanks a lot for your help,

Regards,

Cyril.

 

// create a vector for collecting the header elements

Vector headerElements = new Vector();

// Create a header element in a namespace

org.w3c.dom.Element headerElement =

doc.createElementNS(URI,"jaws:MessageHeader");

headerElement.setAttributeNS(URI,"SOAP-ENV:mustUnderstand","1");

// Create subnodes within the MessageHeader

org.w3c.dom.Element ele = doc.createElement("From");

org.w3c.dom.Text textNode = doc.createTextNode("Me");

org.w3c.dom.Node tempNode = ele.appendChild(textNode);

tempNode = headerElement.appendChild(ele);

ele = doc.createElement("To");

textNode = doc.createTextNode("You");

tempNode = ele.appendChild(textNode);

tempNode = headerElement.appendChild(ele);

ele = doc.createElement("MessageId");

textNode = doc.createTextNode("9999");

tempNode = ele.appendChild(textNode);

tempNode = headerElement.appendChild(ele);

headerElements.add(headerElement);

//Create the SOAP envelope

org.apache.soap.Envelope envelope = new org.apache.soap.Envelope();

//Add the SOAP header element to the envelope

org.apache.soap.Header header = new org.apache.soap.Header();

header.setHeaderEntries(headerElements);

envelope.setHeader(header);

_______________________________
 

Reply via email to