Consuming External Web Service in Apex

By | September 24, 2014

While developing applications in force.com, there may be a requirement where we will need to consume external web service. There are many external websites which provide service and which can be consumed from our applications. One of the features we have in Salesforce is that we can easily consume External Web Services.

Greytrix Releases First Sage ERP Integration for Salesforce.com – Read More about it here.

The first thing you need is the Web Services Description Language (WSDL) file. You will need to download the WSDL of the web service and save on local drive.01

Now go to Salesforce and navigate to “Setup | Develop | Apex Classes”.  On right hand side, you will find button named as “Generate from WSDL”. This button will generate equivalent Apex class to support Web service call. In some Programming languages, these classes are known as Proxy classes or Stubs. When we click on “Generate from WSDL” button, it will prompt for WSDL File. 02Select WSDL file downloaded previously and click on “Parse WSDL” button. 03

And then enter the name by which your class needs to be created. Click on Generate Apex Code, which will create an apex class to support web service call and then click on done.04

Now that the class has been created, we will need to consume it, so before consuming an external web service we have to inform Salesforce that our code will try to get some Data from External source (i.e. it will interact with external system). So, you will need to create a new setting in Remote Site Settings.

In order to do this, navigate to “Setup | Security Control | Remote Site Settings“.  And then create new Site setting for your web service.

About Us
Greytrix as a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners across the globe. We offers Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that requires apex code incorporation into the Salesforce platform.

Greytrix has some unique solutions for Cloud CRM such as Salesforce integration with Sage Enterprise Management (Sage X3), Sage Intacct, Sage 100 and Sage 300 (Sage Accpac). We also offer best-in-class Cloud CRM Salesforce customization and development services along with services such as Salesforce Data Migration, Integrated App development, Custom App development and Technical Support to business partners and end users.

Greytrix GUMU™ integration for Sage ERP – Salesforce is a 5-star app listed on Salesforce AppExchange.

For more information, please contact us at salesforce@greytrix.com. We will be glad to assist you.

Related Posts