{"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":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_83 ez-toc-wrap-left-text counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.dhruvsoft.com\/blog\/creating-custom-apex-soap-based-on-web-services-in-salesforce-com-and-accessing-from-java-application\/#What_Is_SOAP_API\" >What Is SOAP API?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.dhruvsoft.com\/blog\/creating-custom-apex-soap-based-on-web-services-in-salesforce-com-and-accessing-from-java-application\/#What_are_the_Steps\" >What are the Steps?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.dhruvsoft.com\/blog\/creating-custom-apex-soap-based-on-web-services-in-salesforce-com-and-accessing-from-java-application\/#What_are_the_steps_for_Java\" >What are the steps for Java<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-4'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.dhruvsoft.com\/blog\/creating-custom-apex-soap-based-on-web-services-in-salesforce-com-and-accessing-from-java-application\/#Result\" >Result:<\/a><\/li><\/ul><\/nav><\/div>\n<h4><span class=\"ez-toc-section\" id=\"What_Is_SOAP_API\"><\/span>What Is SOAP API?<span class=\"ez-toc-section-end\"><\/span><\/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><span class=\"ez-toc-section\" id=\"What_are_the_Steps\"><\/span>What are the Steps?<span class=\"ez-toc-section-end\"><\/span><\/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><span class=\"ez-toc-section\" id=\"What_are_the_steps_for_Java\"><\/span>What are the steps for Java<span class=\"ez-toc-section-end\"><\/span><\/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><span class=\"ez-toc-section\" id=\"Result\"><\/span>Result:<span class=\"ez-toc-section-end\"><\/span><\/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}]}}