Note that there are some explanatory texts on larger screens.

plurals
  1. POInserting Username token in security header of already generated SOAP envelope gives me two headers!
    primarykey
    data
    text
    <p>I'm using WSS4J to add a Username token in the header of an already formed SOAP request envelope. </p> <p>Here is what the SOAP request looks like: </p> <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://sample03.samples.rampart.apache.org/xsd"&gt; &lt;soapenv:Header/&gt; &lt;soapenv:Body&gt; &lt;xsd:echo&gt; &lt;xsd:param0&gt;hurro kitty&lt;/xsd:param0&gt; &lt;/xsd:echo&gt; &lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt; </code></pre> <p>This is my code (the String, request, is the request above):</p> <pre><code>DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource inStream = new InputSource(); inStream.setCharacterStream(new StringReader(request)); Document document = builder.parse(inStream); WSSecUsernameToken usernametoken = new WSSecUsernameToken(); usernametoken.setPasswordType(WSConstants.PASSWORD_TEXT); usernametoken.setUserInfo(username, password); WSSecHeader secHeader = new WSSecHeader("", false); secHeader.insertSecurityHeader(document); usernametoken.build(document, secHeader); </code></pre> <p>This is my result (notice the header that was inserted is not namespaced correctly, as well as there being two headers): </p> <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://sample03.samples.rampart.apache.org/xsd"&gt; &lt;Header&gt; &lt;wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"&gt; &lt;wsse:UsernameToken wsu:Id="UsernameToken-2765109" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt; &lt;wsse:Username&gt;bob&lt;/wsse:Username&gt; &lt;wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText"&gt;bobPW&lt;/wsse:Password&gt; &lt;/wsse:UsernameToken&gt; &lt;/wsse:Security&gt; &lt;/Header&gt; &lt;soapenv:Header/&gt; &lt;soapenv:Body&gt; &lt;xsd:echo&gt; &lt;xsd:param0&gt;hurro kitty&lt;/xsd:param0&gt; &lt;/xsd:echo&gt; &lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt; </code></pre> <p>What am I doing wrong?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload