Create Web Service with WSS Username Token Polic
- Add @WebService(name="", serviceName="", portName="") annotation for the class.
- Add @Policy(uri = "policy:UsernameToken.xml") for the class.
- Add @WebMethod(operationName="") for method.
- Add @WebResult(name="") for method return name.
- Add @WebParam(name="") for method argument.
- Create policies folder under WEB-INF.
- Put the UsernameToken.xml under policies folder.
<?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>
留言
張貼留言