You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Nicholas Fechner <n....@tallence.com> on 2016/10/10 13:27:13 UTC

SOAP header namespace trouble

Hi,
why, when I do this in a SOAPHandler:

SOAPEnvelope envelope = smc.getMessage().getSOAPPart().getEnvelope();

SOAPHeader header = envelope.getHeader();
if (header == null) {
    header = envelope.addHeader();
}

Name head = envelope.createName("head", "wsse", "http://handler.com");
SOAPHeaderElement auth = header.addHeaderElement(head);

SOAPElement username = auth.addChildElement("UserName");
username.addTextNode(user);

SOAPElement token = auth.addChildElement("Token");
token.addTextNode(this.token);

do I get this as a result:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
   <SOAP-ENV:Header xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
      <wsse:head xmlns:wsse="http://handler.com">
         <UserName>tmcsoap</UserName>
         <Token>kxXafFye9lpZmKg798plf8SjDqS5TjCwKSvZsI7exFE=</Token>
      </wsse:head>
   </SOAP-ENV:Header>
   <soap:Body>
   ...
   </soap:Body>
</soap:Envelope>

Why does CXF (3.1.x in Wildfly 10) use a second namespace for the header?

And help or pointers would be appreciated,
Nicholas


RE: SOAP header namespace trouble

Posted by Andrei Shakirin <as...@talend.com>.
Hi,

The namespaces for Envelope and Header elements are identical and correct: "http://schemas.xmlsoap.org/soap/envelope/".
Different are only the prefixes, but from XML perspective the document is correct.
Do you have any problem to parse it on other side?

Other question: are there good reasons to set username tokens manually instead reusing CXF WS-Security features: http://cxf.apache.org/docs/ws-security.html ?

Regards,
Andrei.

> -----Original Message-----
> From: Nicholas Fechner [mailto:n.fechner@tallence.com]
> Sent: Montag, 10. Oktober 2016 15:27
> To: users@cxf.apache.org
> Subject: SOAP header namespace trouble
> 
> Hi,
> why, when I do this in a SOAPHandler:
> 
> SOAPEnvelope envelope = smc.getMessage().getSOAPPart().getEnvelope();
> 
> SOAPHeader header = envelope.getHeader(); if (header == null) {
>     header = envelope.addHeader();
> }
> 
> Name head = envelope.createName("head", "wsse", "http://handler.com");
> SOAPHeaderElement auth = header.addHeaderElement(head);
> 
> SOAPElement username = auth.addChildElement("UserName");
> username.addTextNode(user);
> 
> SOAPElement token = auth.addChildElement("Token");
> token.addTextNode(this.token);
> 
> do I get this as a result:
> 
> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
>    <SOAP-ENV:Header xmlns:SOAP-
> ENV="http://schemas.xmlsoap.org/soap/envelope/">
>       <wsse:head xmlns:wsse="http://handler.com">
>          <UserName>tmcsoap</UserName>
>          <Token>kxXafFye9lpZmKg798plf8SjDqS5TjCwKSvZsI7exFE=</Token>
>       </wsse:head>
>    </SOAP-ENV:Header>
>    <soap:Body>
>    ...
>    </soap:Body>
> </soap:Envelope>
> 
> Why does CXF (3.1.x in Wildfly 10) use a second namespace for the header?
> 
> And help or pointers would be appreciated, Nicholas