Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.

Webservice Methods

Apex class methods can be exposed as custom SOAP Web service calls. This allows an external application to invoke an Apex Web service to perform an action in Salesforce. Use the webservice keyword to define these methods. For example:
1global class MyWebService {
2    webservice static Id makeContact(String contactLastName, Account a) {
3        Contact c = new Contact(lastName = contactLastName, AccountId = a.Id);
4        insert c;
5        return c.id;
6    }
7}
A developer of an external application can integrate with an Apex class containing webservice methods by generating a WSDL for the class. To generate a WSDL from an Apex class detail page:
  1. In the application from Setup, enter “Apex Classes” in the Quick Find box, then select Apex Classes.
  2. Click the name of a class that contains webservice methods.
  3. Click Generate WSDL.