You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Andy Pahne <ap...@net22.de> on 2007/11/20 11:14:29 UTC

Re: generating SOAP Header Elements - SOLVED

It was easy, I just did not see it at first:

         // add an <ServiceAuthHeader> node
         SOAPHeaderElement authHeader = new SOAPHeaderElement(new 
QName("ServiceAuthHeader"));

         authHeader.setAttribute("xmlns", NAMESPACE);

         SOAPElement userIdNode = authHeader.addChildElement("Username");
         userIdNode.addTextNode(USER_ID);

         SOAPElement passwordNode = authHeader.addChildElement("Password");
         passwordNode.addTextNode(PASSWORD);




But I am still curious: shouldn't those two snippets both work?

Andy



Andy Pahne schrieb:
> 
> I have a problem with a SOAP header element that I added to a webservice 
> request, after the webservice provider "improved" their webservice.
> 
> 
> 
>  SOAPHeaderElement authHeader =  new SOAPHeaderElement(
>      "http://xyz.com/services", "ServiceAuthHeader");
> 
>  SOAPElement userIdNode = authHeader.addChildElement("Username");
>         userIdNode.addTextNode(USER_ID);
> 
>  SOAPElement passwordNode = authHeader.addChildElement("Password");
>  passwordNode.addTextNode(PASSWORD);
> 
>  ((Stub) service).setHeader(authHeader);
> 
> 
> 
> That resultet in generated XML like this:
> 
> 
> <soap:Header>
>   <ns1:ServiceAuthHeader xmlns:ns1="http://xyz.com/services"
>      soap:actor="http://schemas.xmlsoap.org/soap/actor/next"
>      soap:mustUnderstand="0">
>        <ns1:Username>ABC</ns1:Username>
>        <ns1:Password>DEF</ns1:Password>
>   </ns1:ServiceAuthHeader>
> </soap:Header>
> 
> 
> 
> 
> 
> 
> Now, after the upgrade, it just doesn't work anymore. As I am told, the 
> namespace that is added to the header causes the problem. If the header 
> would be more like the following, everything would be fine.
> 
> 
> 
> <soap:Header>
>     <ServiceAuthHeader MyAttribute=""
>          xmlns="http://xyz.com/webservice">
>             <Username>ABC</Username>
>             <Password>DEF</Password>
>     </ServiceAuthHeader>
> </soap:Header>
> 
> 
> 
> I really tried hard to modify the code in order to achieve a result like 
> the above, which works with the remote system, but I couldn't. Is this 
> possible with generated client code?
> 
> Just for curiosity: those two XML-snippets should work equally well, 
> shouldn't they? At least if I understand XML right, or not?
> 
> 
> Best regards,
> Andy
> 
> 
> 
> 
> 


-- 
Andy Pahne
System Architektur & Software Design

net22 GmbH
Ehrenbergweg 24
32760 Detmold

http://www.net22.de

Email     ap@net22.de
Telefon   +49 (5231) 58 06 40
Mobil     +49 (174) 171 68 70

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org