• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Adding SOAP header to the SOAP message

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Destroy anything that stands in your way. Except this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic