aspose file tools*
The moose likes Web Services and the fly likes Adding SOAP header to the SOAP message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Adding SOAP header to the SOAP message" Watch "Adding SOAP header to the SOAP message" New topic
Author

Adding SOAP header to the SOAP message

Anup Bansal
Ranch Hand

Joined: Sep 12, 2006
Posts: 69
Hi ALl,

I am using AXIS 1.4 for the development of a webservice client. I am using WSAD 5.1 as the IDE. I have used the WSDL2Java tool to generate the Client stubs. The remote operation of the webservice that I need to invoke accepts an object as a parameter. Now this object will basically form the body part of the SOAP message.

Can anyone help me with the folowing:
I need to encrypt my SOAP message using XML digital signature. How can I add the header to the SOAP message after invoking the remote method. Can message handlers be used with AXIS?

Thanks & regards,
Anup
Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
Hi,
Check this buddy.

SOAPHeaderElement auth = new SOAPHeaderElement("http://localhost/services/Odds","Authentication");
auth.addChildElement("Username").addTextNode("xxxxx");
auth.addChildElement("Password").addTextNode("xxxxx");
call.addHeader(auth);

So the complete SOAP message will be as follows:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope
xmlns:soapenv = "http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:Authentication
soapenv:actor = "http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand = "0"
xmlns:ns1 = "http://localhost/services/Odds">
<ns1:Username>xxxxx</ns1:Username>
<ns1 asssword>xxxxx</ns1 asssword>
</ns1:Authentication>
</soapenv:Header>
<soapenv:Body>
<GetXMLRaggruppamentiEsiti soapenv:encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"/>
</soapenv:Body>
</soapenv:Envelope>

Hope this will solve the purpose.
raminder.s
Anup Bansal
Ranch Hand

Joined: Sep 12, 2006
Posts: 69
Hi Raminder,

Thanks for the help. I am using the generated stubs to make the call to the webservice. In order to use the suggestion you have mentioned, I will have to modifiy the Stub class. Am I right?

Can I use the handlers to perform the same? If yes, how can I configure the handlers?

Thanks & regards,
Anup
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding SOAP header to the SOAP message