How to attach WS-Policy for Username token validation to a JAX-WS web service in a WebLogic application server

Note: the below has been tried on WebLogic 12c application server running on Linux platform.

Create the policy XML, say CustomUNTPolicy.xml, with the following content:

<?xml version=”1.0″?>
<wsp:Policy xmlns:wsp=”http://schemas.xmlsoap.org/ws/2004/09/policy&#8221; xmlns:sp=”http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512″&gt;
<sp:SupportingTokens>
<wsp:Policy>
<sp:UsernameToken sp:IncludeToken=”http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200512/IncludeToken/AlwaysToRecipient”&gt;
<wsp:Policy>
<sp:WssUsernameToken10/>
</wsp:Policy>
</sp:UsernameToken>
</wsp:Policy>
</sp:SupportingTokens>
</wsp:Policy>

Add CustomUNTPolicy.xml in WEB-INF/policies directory of the web service WAR file.

Deploy the web service WAR

Go to Deployments -> <Web service> -> Configuration -> WS-Policy

Click on the service endpoint name

Select ‘WebLogic’ as the policy kind and click ‘Next’ button

You will see the entry ‘policy:CustomUNTPolicy.xml’ in the ‘Available Endpoint Policies’ table. Select this entry and move it to the ‘Chosen Endpoint Policies’ table. Then click ‘Finish’ button.

The server will prompt you to save the updated deployment plan. Select an appropriate path for the plan XML and click ‘OK’ button.

Click ‘Activate Changes’ button

Depending upon how your application is written, you might have to restart the server.

Advertisements
This entry was posted in Application Server, Java, Java EE, Web Services, WebLogic and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s