---
schema_version: "1"
id: 1af98149b994fb8fa048a225d91dfd49e6a6d9b9919a477bb82fd944e0d77792
title: Using Certificates with SOAP Services
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/apex_callouts_client_certs_soap.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_client_certs_soap.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: b419a43d880a46ab50a82bf869b94f49650228f55c96561d98803336d6e3125e
description: To support two-way authentication for a callout to a SOAP web service, generate a certificate in Salesforce or import a key pair from a keystore into Salesforce. Then integrate the certificate with your Apex.
---
# Using Certificates with SOAP Services

To support two-way authentication for a callout to a SOAP web service, generate a certificate in Salesforce or import a key pair from a keystore into Salesforce. Then integrate the certificate with your Apex.

![Important](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/images/icon_note_important.png)

#### Important

We recommend storing mutual authentication certificates for external web services in a Java keystore. For more information, see [Certificates and Keys](https://help.salesforce.com/articleView?id=security_keys_about.htm&language=en_US).

To integrate the certificate with your Apex:

1. Receive the WSDL for the web service from the third party, or generate it from the application you want to connect to.
2. Generate Apex classes from the WSDL for the web service. See [SOAP Services: Defining a Class from a WSDL Document](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_wsdl2apex.htm).
3. The generated Apex classes include a stub for calling the third-party web service represented by the WSDL document. Edit the Apex classes, and assign a value to a clientCertName\_x variable on an instance of the stub class. The value must match the Unique Name of the certificate that you generated on the Certificate and Key Management page.

This example illustrates editing the Apex classes and works with the sample WSDL file in [Generated WSDL2Apex Code](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_wsdl2apex_gen_code.htm "You can generate Apex classes from a WSDL document using the WSDL2Apex tool. The WSDL2Apex tool is open source and available on GitHub."). The example assumes that you generated a certificate with the Unique Name of DocSampleCert.

docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.clientCertName\_x = 'DocSampleCert';
String input = 'This is the input string';
String output = stub.EchoString(input);

- [← Previous](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_client_certs_generate.htm "Generating Certificates")
- [Next →](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_client_certs_http.htm "Using Certificates with HTTP Requests")