Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Insert SoapHeader Authentication with Axis

843833Oct 2 2006 — edited Oct 3 2006
Hi to all,
I have a Java client that uses Axis to talk to a .NET based web service. I need to insert a soap header on the client side which is expected on the server side as Authentication.
The header I need to insert is the following:

<Authentication xmlns = "http://localhost/services/Odds">
<Username>xxxxx</Username>
<Password>xxxxx</Password>
</Authentication>

So the complete SOAP message will be like follows:

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd = "http://www.w3.org/2001/XMLSchema"
xmlns:SOAP-ENV = "http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header>
<Authentication xmlns = "http://localhost/services/Odds">
<Username>xxxxx</Username>
<Password>xxxxx</Password>
</Authentication>
</SOAP-ENV:Header>
<SOAP-ENV:Body>
<GetXMLRaggruppamentiEsiti xmlns = "undefined"/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I've just tried to use the addHeader method:

SOAPHeaderElement user = new SOAPHeaderElement("http://localhost/services/Odds","Username","xxxxx");
call.addHeader(user);

SOAPHeaderElement pass = new SOAPHeaderElement("http://localhost/services/Odds","Password","xxxxx");
call.addHeader(pass);

but I obtain a message that the .NET web service doesn't accept, the message is the following:


<?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:Username
soapenv:actor = "http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand = "0"
xsi:type = "soapenc:string"
xmlns:ns1 = "http://localhost/services/Odds"
xmlns:soapenc = "http://schemas.xmlsoap.org/soap/encoding/">xxxxx</ns1:Username>
<ns2:Password
soapenv:actor = "http://schemas.xmlsoap.org/soap/actor/next"
soapenv:mustUnderstand = "0"
xsi:type = "soapenc:string"
xmlns:ns2 = "http://localhost/services/Odds"
xmlns:soapenc = "http://schemas.xmlsoap.org/soap/encoding/">xxxxx</ns2:Password>
</soapenv:Header>
<soapenv:Body>
<GetXMLRaggruppamentiEsiti soapenv:encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"/>
</soapenv:Body>
</soapenv:Envelope>


How can be solved this problem?

Thanks in advance.

Andrea Tasca
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 31 2006
Added on Oct 2 2006
1 comment
566 views