top of page

APEX Web Services:

SOAP VS REST API:

SOAP will have a single endpoint or URI like https://<>/message

Client request message is send via XML that has information about the Operation/Method and the data it will work on.

For eg,

<delete>

<messageid>1234</messageid>

</delete>

SOAP uses http and xml.

REST API - has multiple URIs for multiple operations.

The client request message has the data and the HTTP method (GET, POST, PUT) that will work on the data.

When the client request using the Resource URI - https://<api>/<resource name> is send using GET, it is handled by a class - that the developer has implemented to handle this resource request.

Each resource request should have a corresponding class that handles the request.

The handler class should have the following annotations:

Path - to map to the resource path

HTTP method annotation - eg, if GET is used in the request the method to call.

Produce - the format of the response - Plain Text or JSON or any other format.


Make Callouts to External Services from Apex

An Apex callout enables you to tightly integrate your Apex code with an external service. The callout makes a call to an external web service or sends an HTTP request from Apex code, and then receives the response.

Apex callouts come in two flavors.

  • Web service callouts to SOAP web services use XML, and typically require a WSDL document for code generation.

  • HTTP callouts to services typically use REST with JSON.

These two types of callouts are similar in terms of sending a request to a service and receiving a response. But while WSDL-based callouts apply to SOAP Web services,

HTTP callouts can be used with any HTTP service, either SOAP or REST.

You’ll probably use SOAP mostly when integrating with legacy applications or for transactions that require a formal exchange format or stateful operations.


Authorize Endpoint Addresses

Before you start working with callouts, update the list of approved sites for your org on the Remote Site Settings page.


REST - HTTP and Callout Basics

REST callouts are based on HTTP.

Each callout request is associated with an HTTP method and an endpoint.

The HTTP method indicates what type of action is desired.

The following are descriptions of common HTTP methods.


Table 1. Some Common HTTP Methods




Recent Posts

See All
Apex as a Web Service

Use case: By using one interface, call center representatives can view and update case records in Salesforce and access internal...

 
 
 

Comments


Post: Blog2_Post

©2020 by SalesforceDemystified. Proudly created with Wix.com

bottom of page