Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
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.
To integrate the certificate with your Apex:
- Receive the WSDL for the web service from the third party, or generate it from the application you want to connect to.
- Generate Apex classes from the WSDL for the web service. See SOAP Services: Defining a Class from a WSDL Document.
- 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. The example assumes that you generated a certificate with the Unique Name of DocSampleCert.
1docSample.DocSamplePort stub = new docSample.DocSamplePort();
2stub.clientCertName_x = 'DocSampleCert';
3String input = 'This is the input string';
4String output = stub.EchoString(input);