+ Start a Discussion
Sachin Bhalerao 17Sachin Bhalerao 17 

How to call APEX SOAP services through Workbench ?

Dear Team ,

Greetings !!!

Thank you for your support . I have created one APEX class for SOAP service it contains one method to insert data into Account Standard object . Plz let me know how i call this class and metod through Workbench tool . This is my code

class name : accSOAPint 

global class accSOAPint {

    webservice static Account dopost(String Name){
        Account acc = new Account();
        acc.Name = Name;
        insert acc;
        return acc;
        
    }
}

Thanks & Regards
Sachin Bhalerao
Alain CabonAlain Cabon
Not direct like the easier REST calls by using the workbench because you need to get a session Id at first but it is also possible.

How to consume a soap web service using workbench?
https://salesforce.stackexchange.com/questions/126564/how-to-consume-a-soap-web-service-using-workbench
 
Sachin Bhalerao 17Sachin Bhalerao 17
Hi Alian ,

I have this code :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:partner.soap.sforce.com/class/dopost">
   <soapenv:Header>
      <urn:CallOptions>
         <urn:client></urn:client>
         <urn:defaultNamespace></urn:defaultNamespace>
      </urn:CallOptions>
      <urn:LoginScopeHeader>
         <urn:organizationId></urn:organizationId>

ID : 00D2v000001wLx1!AQUAQCyEYtQRhwkPWPXCno5R4K7G6wdN2E2TKh27ftBsxmu9PMI.LgSe_wCPs3UpCcS.JYZOpaAhF_Q8pG29lCp29VSQdt_z

Plz share proper code

Thanks & Regards
Sachin Bhalerao
Alain CabonAlain Cabon
You are very close to the goal. Congrats!

The last step is very easy by just replacing MyWebService with accSOAPint 
 
global class MyWebService {
    webService static String makeContact(String firstName, String lastName) {
        return 'Hello '+firstName+' ' +lastName;
    }
}

1) Button : Generate WSDL  : check for the target URLs

<definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://soap.sforce.com/schemas/class/MyWebService" targetNamespace="http://soap.sforce.com/schemas/class/MyWebService">
<types>
<xsd:schema elementFormDefault="qualified" targetNamespace="http://soap.sforce.com/schemas/class/MyWebService">
 
<xsd:element name="makeContact">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="firstName" type="xsd:string" nillable="true"/>
<xsd:element name="lastName" type="xsd:string" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="makeContactResponse">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="result" type="xsd:string" nillable="true"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>


2) sarojkbera is useless by default. It is an org Namespace.  If you’re not creating managed packages for distribution then registering a namespace prefix isn’t required, but it’s a best practice for all but the smallest organizations.

/services/Soap/class/MyWebService

User-added image

xmlns:myw can be reused like above but be careful because you are using dopost instead of makeContact (Name instead of firstName ...)

https://salesforce.stackexchange.com/questions/126564/how-to-consume-a-soap-web-service-using-workbench

 
Bouchard MichaudBouchard Michaud
WSDL2Apex automatically generates Apex classes from a WSDL document. You download the web service’s WSDL file, and then you upload the WSDL and WSDL2Apex generates the Apex classes for you myprepaidcenter (https://www.myprepaidcenter.pro)