SOAP API Implementation in Salesforce – Beginner’s Basic 102

This post will take it forward from our last post we discussed the basics of SOAP Integration methodology and terminologies.

For this demo on Soap calls, we are taking a case of simple Salesforce to Salesforce Integration.

Lets try Hands-On Example

We will go as per the steps discussed and will keep it concise.. Shall we begin?

1. Create a webservice method on the server-side

The webservice method should be under a global class to be accessible externally. And we can put in our entire logic in this class that we want to expose externally as a service.

Let’s create a simple webservice method to create an account record.

2. Generate WSDL file for the created webservice class on the server-side

After saving the class, go to Setup | Apex Class and click on the class and generate WSDL to download the required file.

Generate WSDL file

3. Generate Partner/Enterprise WSDL on the server-side

Search API in quick find box to generate required WSDL for next step. We are using Partner WSDL for this case. We have discussed the details in the last post.

Download Partner API

4. Consume/Parse both the WSDL files in the client-side

We log in at the client-side server, (here Salesforce) and consume the webservice WSDL files to generate the required apex code. We receive two classes for synchronous and asynchronous processing each.

Apex classes developed from exposed webservice class

In similar fashion, we generate the apex code from the Partner WSDL from the server.

Apex classes developed from server-side Partner WSDL

5. Invoke the webservice from the client-side

Now here comes the main job. How do we invoke a webservice on the server-side, from the client-server, is what Integration is about. Let’s dig in!

Anonymous Window :

Debug Log Output on Client-side

Sergio Marquina : Record Created on the server-side.

Common Errors Encountered

One error encountered during parsing WSDL was “invalid type : anyType”, this can be simply rectified by finding and replacing it with “type : stringType”.

The second error or more like another security setting to remember is adding the remote site settings, on the server which is trying to connect to any endpoint URL. It can be added easily by finding remote site settings in the Quick Find box.

As SOAP Integration is more complex in nature, we usually prefer to go for Restful services. Will be discussing it next!

Want to learn more technicalities on Soap Integration? This article might interest you..

2 thoughts on “SOAP API Implementation in Salesforce – Beginner’s Basic 102”

Leave a comment

error: Content is protected !!