Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Information about required tokens can be published in WSDL using WS-Policies. For username token I use the following policy:</p> <pre><code>&lt;wsp:Policy wsu:Id="UP_policy" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&gt; &lt;sp:SupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"&gt; &lt;wsp:Policy&gt; &lt;sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"&gt; &lt;wsp:Policy&gt; &lt;sp:WssUsernameToken11 /&gt; &lt;/wsp:Policy&gt; &lt;/sp:UsernameToken&gt; &lt;/wsp:Policy&gt; &lt;/sp:SupportingTokens&gt; &lt;/wsp:Policy&gt; </code></pre> <p>It requires UT only for request message (<code>AlwaysToRecipient</code>). To include such policy in your generated WSDL:</p> <ul> <li>save it to file available in classpath, e.g. <code>ut.policy.xml</code></li> <li>add <code>@Policies({ @Policy(uri = "ut.policy.xml") })</code> annotations to your service class or interface</li> </ul> <p>I modified example CXF project. It shows how to do that. You can find it <a href="https://github.com/destin/SO-answers/tree/master/SO-how-to-add-soap-security-header-usernametoken-information-to-code-first-webser" rel="nofollow">here</a>.</p> <p>As a result your WSDL will have appropriate instance of WS-SecurityPolicy attached, telling clients that Username token is expected:</p> <pre><code>&lt;wsdl:definitions ...&gt; ... &lt;wsdl:service name="GreeterService"&gt; &lt;wsdl:port binding="tns:GreeterServiceSoapBinding" name="GreeterPort"&gt; &lt;soap:address location="http://localhost:9000/SoapContext/GreeterPort"/&gt; &lt;/wsdl:port&gt; &lt;wsp:PolicyReference URI="#UP_policy"/&gt; &lt;/wsdl:service&gt; &lt;wsp:Policy xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" wsu:Id="UP_policy"&gt; &lt;sp:SupportingTokens xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"&gt; &lt;wsp:Policy&gt; &lt;sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702/IncludeToken/AlwaysToRecipient"&gt; &lt;wsp:Policy&gt; &lt;sp:WssUsernameToken11/&gt; &lt;/wsp:Policy&gt; &lt;/sp:UsernameToken&gt; &lt;/wsp:Policy&gt; &lt;/sp:SupportingTokens&gt; &lt;/wsp:Policy&gt; &lt;/wsdl:definitions&gt; </code></pre> <p>More about configuring WS-SecurityPolicy with CXF can be found <a href="http://cxf.apache.org/docs/ws-securitypolicy.html" rel="nofollow">here</a> and how to handle any WS-Policy <a href="http://cxf.apache.org/docs/ws-policy.html" rel="nofollow">here</a>.</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.
    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