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.
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.
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.
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.
In similar fashion, we generate the apex code from the Partner WSDL from the server.
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
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”