Posts

Showing posts with the label WebService

Exposing Apex Methods as SOAP Web Services

By exposing them as SOAP web services, apex methods are available to external applications. To make Apex methods available as SOAP web services, we must declare them within a global Apex class and use the "webservice" keyword. Salesforce will then automatically create a WSDL document for that class, which can be utilized by external applications to access the exposed web services. Example global class MyWebService {     webservice static Id makeContact(String contactLastName, Account a) {         Contact c = new Contact(lastName = contactLastName, AccountId = a.Id);         insert c;         return c.id;     } } To generate the WSDL file for a Salesforce instance, we can simply append "?wsdl" to the instance URL, followed by the path to the Apex class.  For example, the URL should look like https://yourinstance.salesforce.com/services/wsdl/class/MyWebService. Once you have the WSDL file, you can generat...