Create Web Service with WSS Username Token Polic

  1. Add @WebService(name="", serviceName="", portName="") annotation for the class.
  2. Add @Policy(uri = "policy:UsernameToken.xml") for the class.
  3. Add @WebMethod(operationName="") for method.
  4. Add @WebResult(name="") for method return name.
  5. Add @WebParam(name="") for method argument.
  6. Create policies folder under WEB-INF.
  7. Put the UsernameToken.xml under policies folder.
The content of the xml file:
<?xml version="1.0"?>
<wsp:Policy
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512"
>
<sp:SupportingTokens>
<wsp:Policy>
<sp:UsernameToken sp:IncludeToken="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:WssUsernameToken10/>
</wsp:Policy>
</sp:UsernameToken>
</wsp:Policy>
</sp:SupportingTokens>
</wsp:Policy>

留言

這個網誌中的熱門文章

Disable ionic's sidemenu content drag to toggle menu

Multiple writable mappings exist for the field. Only one may be defined as writable, all others must be specified read-only.

java.lang.NoClassDefFoundError: org/apache/xerces/jaxp/datatype/XMLGregorianCalendarImpl$Parser