Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • 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
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

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
 
get schwifty. tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic