Saturday, 14 July 2012

Web Services

  
* Web Services can convert your applications into Web-applications.
* Web Services are published, found, and used through the Web.
* Web services are typically application programming interfaces (API) or Web APIs that are accessed via Hypertext Transfer Protocol (HTTP) and executed on a remote system hosting the requested services. 
* Web services are application (software) components that run over the internet using XML.
* Web services can be used by other applications. 
How Does it Work?
* The basic Web services platform is XML + HTTP.
*XML provides a language which can be used between different platforms and programming languages and still express complex messages and functions.
*The HTTP protocol is the most used Internet protocol.
*Web services platform elements:
SOAP (Simple Object Access Protocol)
UDDI (Universal Description, Discovery and Integration)
WSDL (Web Services Description Language)

Exposing Apex Methods as Web Services:
 * To expose your Apex methods, use WebService.
* You can expose your Apex methods so that external applications can access your
code and your application.
Note:
* Apex Web services allow an external application to invoke Apex methods through Web services.
   (Nothing but 'call in', external application use our apex methods)
* Apex callouts enable Apex to invoke external web or HTTP services.

WebService Methods:
* Apex class methods can be exposed as custom Force.comWeb services API 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.
global class MyWebService {
webService static Id makeContact(String lastName, Account a) {
Contact c = new Contact(lastName = 'Weissman', AccountId = a.Id);
insert c;
return c.id;
}
}
*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 navigate to Your Name ➤ Setup ➤ Develop ➤ Apex Classes.
2. Click the name of a class that contains webService methods.
3. Click Generate WSDL.
Exposing Data with WebService Methods:
* Invoking a custom webService method always uses System context.
* Apex class methods that are exposed through the API with the webService keyword do not observe object permissions, field-level security, or sharing rules for any records, unless the methods are contained in a class defined using the with sharing keyword.
* Only classes defined using with sharing respect sharing rules for current user.


No comments:

Post a Comment

Labels