This section demonstrates adding security to the web service client that references the web service created in the previous section. This web service is secured using the security mechanism described in Mutual Certificates Security.
To add security to the client that references this web service, complete the following steps.
Create the client application following the steps described in Creating a Client to Consume a WSIT-Enabled Web Service.
Whenever you make changes on the service, refresh the client so that the client will pick up the change. To refresh the client, right-click the node for the Web Service Reference for the client, and select Refresh Client.
Expand the node for the web service client, CalculatorWSServletClient.
Expand the node for Web Service References.
Right-click CalculatorWSService and select Edit Web Service Attributes.
Select the WSIT Configuration tab of the CalculatorWSService dialog.
Provide the client’s private key by pointing to an alias in the keystore. To do this, expand the Certificates node, click the Load Aliases button for the keystore, then select xws-security-client from the Alias list.
Provide the server’s certificate by pointing to an alias in the client truststore. To do this, from the Certificates node, click the Load Aliases button for the truststore and select xws-security-server from the Alias list. Click OK to close this dialog.
In the tree, drill down from the project to Source Packages->META-INF. Double-click on CalculatorWSService.xml, and verify that lines similar to the following are present:
<wsp:All> <wsaws:UsingAddressing xmlns:wsaws="http://www.w3.org/2006/05/addressing/wsdl"/> <sc:KeyStore wspp:visibility="private" location="C:\Sun\glassfish\domains\domain1\config\keystore.jks" storepass="changeit" alias="xws-security-server" keypass="changeit"/> <sc:TrustStore wspp:visibility="private" location="C:\Sun\glassfish\domains\domain1\config\cacerts.jks" storepass="changeit" peeralias="xws-security-server"/> </wsp:All>
Compile and run this application by right-clicking the CalculatorWSServletClient node and selecting Run Project.