Salesforce WebService Integration
Content
- Description
- Requirements
- Writing WebMethod
- Exposing WebMethod
- Consuming WebMethod
- Notes
1. Description
Nowadays the business becomes more complex. To make B2B transactions successfully, the Salesforce Web Service plays a major role. Salesforce comes with various solutions to provide their consumers to expose organization data to external systems for data integrity. Salesforce provides both provider and consumer approach to the World. Using Webservice Salesforce enables you as a provider you can expose your org data to the World.
2. Requirements
- Salesforce Connected-App
- Integration-User Setup
- Salesforce Apex Class
- External Tools to Test
3. Writing Web Method
Apex Class
4. Exposing Web Method
Before writing Web Method, you need to configure connected app.
A connected app is a framework that
enables an external application to integrate with Salesforce using APIs and
standard protocols, such as SAML, OAuth, and OpenID Connect. Connected apps use
these protocols to authenticate, authorize, and provide single sign-on (SSO)
for external apps.
https://help.salesforce.com/articleView?id=sf.connected_app_overview.htm&type=5
Using Connected App, you will get Client ID and Client Secret.
Setup à Create à App à Connected
App à New
After creating the connected app, you will
get consumer key and consumer secret.
Create an Integration User of Integration API Only Profile and get Integration user id, password and Security token.
5. Consuming WebMethod
Consuming a Webservice Method needs 2 steps
- Authentication URL for generating security token
- Using security token to send payload (XML Body) to Salesforce.
Method: Post
URL: https://test.my.salesforce.com/services/Soap/class/CreateCustomer
Header:
- SOAPAction – CreateContact
- Content-Type -- text/xml
Body:
<?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cc="http://soap.sf orce.com/schemas/class/CreateCustomer">
<soapenv:Header>
<cc:SessionHeader>
<cc:sessionId>
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
</cc:sessionId>
</cc:SessionHeader>
</soapenv:Header>
<soapenv:Body>
<cc:CreateContact>
<cc:lastName>MANAS</cc:lastName>
</cc:CreateContact>
</soapenv:Body>
</soapenv:Envelope>
6. Note
- You can use the postman or SOAP API to consume web service for testing purpose
- Use Callback URL: https://www.getpostman.com/oauth2/callback
Nice stuff, It's really helpful 👍
ReplyDeleteThanks
DeleteWell presented.
ReplyDeleteThanks
DeleteThis comment has been removed by the author.
DeleteWell written helpful information.
ReplyDeleteThanks for sharing.