# WebServiceA.jws Sample

This topic inludes the source code for the WebServiceA.jws Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebServices/security/transport/clientCert/

## Sample Source Code

`01 package security.transport.clientCert; 02 03 /** 04 * A simple web service that demonstrates how to send a client certificate. 05 * 06 * Note client certificates are enabled in SamplesApp, but they 07 * are not enforced. For this reason, WebServiceA can still successfully 08 * invoke WebServiceB (and receive a callback from WebServiceB), even if WebServiceA 09 * does not succeed in sending a client certificate to WebServiceB. 10 */ 11 12 import java.io.File; 13 import weblogic.Home; 14 15 /** 16 * @common:target-namespace namespace="http://openuri.org/bea/samples/workshop/clientcert/webservicea" 17 */ 18 public class WebServiceA implements com.bea.jws.WebService 19 { 20 /** @common:control */ 21 security.transport.clientCert.WebServiceBControl ctrl; 22 23 /** 24 * @common:operation 25 */ 26 public void invokeWebServiceB() 27 { 28 /** 29 * Enable client certificates for this web service. 30 */ 31 ctrl.useClientKeySSL( true ); 32 33 /** 34 * Specify the location and password for the keystore where the client certificates resides 35 * 36 * The following method call to setKeystore is, strictly speaking, 37 * unnecessary, since SamplesApp is already configured to use the 38 * default keystore DemoIdentity.jks. 39 * The call to the setKeystore() method is included to show how you would set the 40 * location for another, non-default keystore. 41 */ 42 ctrl.setKeystore(Home.getPath() + "/lib/DemoIdentity.jks", "DemoIdentityKeyStorePassPhrase" ); 43 44 /** 45 * Specify the alias in the keystore for both the client SSL certificate 46 * and the client private key. (The certificate and the private key must 47 * be stored under the same alias in the same keystore.) 48 * The second parameter specifies the password required to access 49 * the keystore. 50 */ 51 ctrl.setClientCert("DemoIdentity", "DemoIdentityPassPhrase"); 52 53 /** 54 * Invoke the requestCallback method on WebServiceB. 55 */ 56 ctrl.requestCallback("WebServiceA"); 57 } 58 59 public void ctrl_result(java.lang.String message) 60 { 61 /** 62 * In a real world example, WebServiceA would do something with 63 * the callback recieved from WebServiceB. 64 */ 65 } 66 }`