{"id":252,"date":"2014-02-04T18:31:46","date_gmt":"2014-02-04T13:01:46","guid":{"rendered":"https:\/\/www.dhruvsoft.com\/blog\/?p=252"},"modified":"2025-06-05T13:02:11","modified_gmt":"2025-06-05T07:32:11","slug":"creating-custom-apex-soap-based-on-web-services-in-salesforce-com-and-accessing-from-java-application","status":"publish","type":"post","link":"https:\/\/www.dhruvsoft.com\/blog\/creating-custom-apex-soap-based-on-web-services-in-salesforce-com-and-accessing-from-java-application\/","title":{"rendered":"Creating custom Apex SOAP based on Web Services in Salesforce.com and accessing from Java Application"},"content":{"rendered":"<h4>What Is SOAP API?<\/h4>\n<p>SOAP API is used to create, retrieve, update or delete records, such as accounts, leads, and custom objects. It supports data in the form of XML. Requires WSDL files for the integration.<\/p>\n<p><!--more--><\/p>\n<h4>What are the Steps?<\/h4>\n<ul>\n<li>Navigate to setup -&gt; Develop -&gt; Apex Classes and create new class by clicking new button.<\/li>\n<\/ul>\n<ul>\n<li>Write a class with \u00e2\u20ac\u0153global\u00e2\u20ac\u009d access modifier with methods.<\/li>\n<\/ul>\n<ul>\n<li>Methods must be start with \u00e2\u20ac\u0153Webservice\u00e2\u20ac\u009d keyword.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-245\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/1.png\" alt=\"1\" width=\"668\" height=\"285\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/1.png 668w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/1-300x127.png 300w\" sizes=\"auto, (max-width: 668px) 100vw, 668px\" \/><\/a><\/p>\n<ul>\n<li>Save the above class. After saving the class you will see the button \u00e2\u20ac\u0153Generate WSDL\u00e2\u20ac\u009d. Click on that to get WSDL for web service. Save the WSDL file named as \u00e2\u20ac\u0153SuryaDhruvsoftWebservice.wsdl\u00e2\u20ac\u009d<\/li>\n<\/ul>\n<ul>\n<li>Now we will see how to access this WSDL file using JAVA<\/li>\n<\/ul>\n<h4>What are the steps for Java<\/h4>\n<ul>\n<li>Create a Dynamic web project named as \u00e2\u20ac\u0153ApexSOApCustomWS\u00e2\u20ac\u009d in eclipse.<\/li>\n<\/ul>\n<ul>\n<li>Generate a Enterprise\/Partner WSDL from your salesforce org which can be used to get a SessionId.<\/li>\n<\/ul>\n<ul>\n<li>Import Enterprise\/Partner WSDL file into the project and generate client side stubs<\/li>\n<\/ul>\n<ul>\n<li>Import \u00e2\u20ac\u0153SuryaDhruvsoftWebservice.wsdl\u00e2\u20ac\u009d file into the project and generate client side stubs by right clicking on the WSDL file and click on \u00e2\u20ac\u0153Generate Client\u00e2\u20ac\u009d<\/li>\n<\/ul>\n<ul>\n<li>The below image shows code generated for Partner WSDL in Blue color box and code for Custom Web Service (SuryaDhruvsoftWebservice.wsdl) in Red color box.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-249\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/2.png\" alt=\"2\" width=\"637\" height=\"473\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/2.png 637w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/2-300x222.png 300w\" sizes=\"auto, (max-width: 637px) 100vw, 637px\" \/><\/a><\/p>\n<ul>\n<li>Create Servlet named as \u00e2\u20ac\u0153 HandleWebService\u00e2\u20ac\u009d with following code in your eclipse project<\/li>\n<\/ul>\n<ul>\n<li><a href=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-250\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/3.png\" alt=\"3\" width=\"668\" height=\"588\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/3.png 668w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/3-300x264.png 300w\" sizes=\"auto, (max-width: 668px) 100vw, 668px\" \/><\/a><a href=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-medium wp-image-251\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/4.png\" alt=\"4\" width=\"1\" height=\"1\" \/><\/a><a href=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-255\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/4.png\" alt=\"4\" width=\"668\" height=\"573\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/4.png 668w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/4-300x257.png 300w\" sizes=\"auto, (max-width: 668px) 100vw, 668px\" \/><\/a>Create JSP page named as \u00e2\u20ac\u0153AccessSalesforceCustomWS\u00e2\u20ac\u009d with following code in your eclipse project<\/li>\n<\/ul>\n<p><a href=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-253\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/5.png\" alt=\"5\" width=\"668\" height=\"461\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/5.png 668w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/5-300x207.png 300w\" sizes=\"auto, (max-width: 668px) 100vw, 668px\" \/><\/a><\/p>\n<ul>\n<li>Run the above created JSP page and enter your name then click the submit button<\/li>\n<\/ul>\n<h4>Result:<\/h4>\n<p><a href=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-248\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/6.png\" alt=\"6\" width=\"623\" height=\"290\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/6.png 623w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/6-300x139.png 300w\" sizes=\"auto, (max-width: 623px) 100vw, 623px\" \/><\/a><a href=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-254\" src=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/7.png\" alt=\"7\" width=\"665\" height=\"173\" srcset=\"https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/7.png 665w, https:\/\/www.dhruvsoft.com\/blog\/wp-content\/uploads\/2014\/02\/7-300x78.png 300w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>What Is SOAP API? SOAP API is used to create, retrieve, update or delete records, such as accounts, leads, and custom objects. It supports data in the form of XML. Requires WSDL files for the integration.<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[58],"tags":[104,107,106,105],"class_list":["post-252","post","type-post","status-publish","format-standard","hentry","category-apex","tag-apex-soap","tag-apex-soap-on-web-services","tag-creating-custom-apex-soap","tag-custom-apex-soap","entry"],"_links":{"self":[{"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/posts\/252","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/comments?post=252"}],"version-history":[{"count":0,"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/posts\/252\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/media?parent=252"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/categories?post=252"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dhruvsoft.com\/blog\/wp-json\/wp\/v2\/tags?post=252"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}