Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Adding SOAP header to the SOAP message

 
Anup Bansal
Ranch Hand
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 69
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic