{"id":720,"date":"2014-09-24T11:29:02","date_gmt":"2014-09-24T11:29:02","guid":{"rendered":"http:\/\/www.greytrix.com\/blogs\/salesforce\/?p=720"},"modified":"2025-05-29T09:18:06","modified_gmt":"2025-05-29T09:18:06","slug":"consuming-external-web-service-in-apex","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/09\/24\/consuming-external-web-service-in-apex\/","title":{"rendered":"Consuming External Web Service in Apex"},"content":{"rendered":"<p style=\"text-align: justify;\">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.<\/p>\n<p><a title=\"Salesforce.com integration with Sage 100 (MAS 90\/200) ERP \u2013 An introduction\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2015\/01\/21\/salesforce-integration-with-sage-100\/\" target=\"_blank\" rel=\"noopener\">Greytrix Releases First Sage ERP Integration for Salesforce.com &#8211; Read More about it here.<\/a><\/p>\n<p style=\"text-align: justify;\">The first thing you need is the Web Services Description Language (WSDL)\u00a0file. You will need to download the WSDL of the web service and save on local drive.<a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/09\/01.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-721\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/09\/01.jpg\" alt=\"01\" width=\"210\" height=\"127\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">Now go to Salesforce and navigate to\u00a0<strong>\u201cSetup | Develop | Apex Classes\u201d<\/strong>.\u00a0 On right hand side, you will find button named as <strong>\u201cGenerate from WSDL\u201d<\/strong>. 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 \u201cGenerate from WSDL\u201d button, it will prompt for WSDL File.\u00a0<a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/09\/02.jpg\"><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter size-full wp-image-722\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/09\/02.jpg\" alt=\"02\" width=\"1159\" height=\"274\" \/><\/a>Select WSDL file downloaded previously and click on \u201cParse WSDL\u201d button.\u00a0<a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/09\/03.jpg\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-723\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/09\/03.jpg\" alt=\"03\" width=\"726\" height=\"114\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">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.<a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/09\/04.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-724\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2014\/09\/04.jpg\" alt=\"04\" width=\"502\" height=\"29\" \/><\/a><\/p>\n<p style=\"text-align: justify;\">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.<\/p>\n<p style=\"text-align: justify;\">In order to do this, navigate to \u201c<strong>Setup | Security Control | Remote Site Settings<\/strong>\u201c. \u00a0And then create new Site setting for your web service.<\/p>\n<p><span style=\"font-size: Medium;\"><strong>About Us<\/strong><\/span><br \/>\n<a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a> 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.<\/p>\n<p><a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a> has some unique solutions for Cloud CRM such as Salesforce integration with <a href=\"https:\/\/www.greytrix.com\/product\/sage-x3\/gumu-x3-salesforce-integration\">Sage Enterprise Management (Sage X3<\/a>), Sage Intacct, <a href=\"https:\/\/www.greytrix.com\/product\/sage-100-erp\/gumu-100-salesforce-integration\">Sage 100 <\/a>and <a href=\"https:\/\/www.greytrix.com\/product\/sage-300-erp\/gumu-300-salesforce-integration\">Sage 300 (Sage Accpac)<\/a>. We also offer best-in-class Cloud CRM <a href=\"https:\/\/www.greytrix.com\/product\/crm-development\/salesforce-com\">Salesforce customization and development services<\/a> along with services such as Salesforce <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/data-migration-services\">Data Migration<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/integrated-application-development\">Integrated App development<\/a>, <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/custom-development\">Custom App development<\/a> and <a href=\"https:\/\/www.greytrix.com\/product\/professional-services\/maintenance-support\">Technical Support<\/a> to business partners and end users.<\/p>\n<p>Greytrix GUMU&#x2122; integration for Sage ERP \u2013 Salesforce is a 5-star app listed on <a href=\"https:\/\/appexchange.salesforce.com\/listingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noopener\">Salesforce AppExchange<\/a>.<\/p>\n<p>For more information, please contact us at <a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n<p><strong><span style=\"font-size: Medium;\">Related Posts<\/span><\/strong><\/p>\n<ul>\n<li><a title=\"Create Button for List View\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/09\/24\/create-button-for-list-view\/\" target=\"_blank\" rel=\"noopener\">Create Button for List View\u00a0<\/a><\/li>\n<li><a title=\"Request updated information from Salesforce contacts\" href=\"http:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/08\/30\/request-updated-information-from-salesforce-contacts\/\" target=\"_blank\" rel=\"noopener\">Request updated information from Salesforce contacts<\/a><\/li>\n<li><a title=\"Quickly add fields to Existing Object without using standard wizard\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/08\/26\/quickly-add-fields-to-existing-object-without-using-standard-wizard\/\" target=\"_blank\" rel=\"noopener\">Quickly add fields to Existing Object without using standard wizard<\/a><\/li>\n<li><a title=\"Mass Transfer Custom Object Records from One User to Another\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/08\/26\/mass-transfer-custom-object-records-from-one-user-to-another\/\" target=\"_blank\" rel=\"noopener\">Mass Transfer Custom Object Records from One User to Another<\/a><\/li>\n<li><a title=\"Remove None option from a Picklist in Salesforce\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/07\/09\/remove-none-option-from-a-picklist-in-salesforce\/\" target=\"_blank\" rel=\"noopener\">Remove None option from a Picklist in Salesforce<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>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\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2014\/09\/24\/consuming-external-web-service-in-apex\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[13,529,597,599,548,598],"class_list":["post-720","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-apex","tag-web-service","tag-web-service-in-apex","tag-web-services-description-language-file","tag-wsdl","tag-wsdl-file"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=720"}],"version-history":[{"count":5,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/720\/revisions"}],"predecessor-version":[{"id":10801,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/720\/revisions\/10801"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}