+ Start a Discussion
shrey.tyagi88@tcs.comshrey.tyagi88@tcs.com 

Salesforce Inbound Integration Pattern - Basic Questions

Hi Everyone,
          I am a newbie to Salesforce Integrations and I am reading a lot of stuff to get hang of how SOAP and REST integrations are done . I have few very basic questions related to patterns , if anyone can help me out with them , that would be great. Please find them given below:

Q1. For an inbound integration, we have 2 options (as per my knowledge). One is to create an apex class and expose it as a web service , so that it can be consumed by external entity (C# or Java platform). This code will be used in whatever DML operations  that are required . Second option is to ask the Java/C# side developers to write their own code and provide their code login access to salesforce by adding the application under remote side settings. How do we choose which approach to take? 

Q2. While making HTTP callouts to external systems , we usedifferent type of encoding like given below:

String authorizationHeader = 'BASIC ' + EncodingUtil.base64Encode(headerValue);
String encodedPropAddress = EncodingUtil.urlEncode(Rec.a__c,'UTF-8');

How do we know which format is to be used when ? As in when to use base64 . Will it be provided to me as a salesforce developer by technicians of external systems (to which callouts are being made)?

I do know that these questions might sound to you as very basic ones , but I am bit confused . So I would really appriciate if someone can throw some light on them.

Thanks a lot for your help!!!

Regards
Shrey Tyagi
Best Answer chosen by shrey.tyagi88@tcs.com
daniel_hdaniel_h
Q1: I usually do the integration using standard Salesforce APIs. You're going to have to do coding in C#/Java either way, so why not keep the code to a minimum? Also, I usually don't write code for my external integrations. Instead I use an existing 3rd party tool. This can be the free data loader which can be run from command line and thus automated. There are also a ton of other tools such as Jitterbit, Workato, Mulesoft that can integrate with Salesforce.

Q2: When making callouts, use Named Credentials to store your user name and passwords instead of building them in Apex. Then you don't have to worry about authentication headers. For the UTF-8 encoding, that might be necessary for the endpoint you are calling.

All Answers

daniel_hdaniel_h
Q1: I usually do the integration using standard Salesforce APIs. You're going to have to do coding in C#/Java either way, so why not keep the code to a minimum? Also, I usually don't write code for my external integrations. Instead I use an existing 3rd party tool. This can be the free data loader which can be run from command line and thus automated. There are also a ton of other tools such as Jitterbit, Workato, Mulesoft that can integrate with Salesforce.

Q2: When making callouts, use Named Credentials to store your user name and passwords instead of building them in Apex. Then you don't have to worry about authentication headers. For the UTF-8 encoding, that might be necessary for the endpoint you are calling.
This was selected as the best answer
shrey.tyagi88@tcs.comshrey.tyagi88@tcs.com
Hi Daniel,
     Well first of all , thank you very much for your quick response. I really appriciate that . So continuing with question 1 in my previous post , as per your comments we dont need any code. So if for example I need an external entity to delete an account record in my sfdc org , rather than writing the code given below:

@RestResource(urlMapping='/Account/*')
global with sharing class MyRestResource

@HttpDelete
 global static void doDelete() {

        RestRequest req = RestContext.request;
        RestResponse res = RestContext.response;
        String accountId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
        Account account = [SELECT Id FROM Account WHERE Id = :accountId];
        delete account;
}

I can simply configure Jitterbit with my sfdc and external app to do the job? Isn't this the same concept as workbench REST explorer , there also we just send the URL and it does the DML job in our salesforce org. We dont write any specific piece of code for that.

Thanks again for your time.


Regards
Shrey Tyagi
daniel_hdaniel_h
I wouldn't use Jitterbit in the middle of something like that. (You could though, I think.) Jitterbit and the other tools are best for batch processes. If you want to delete a record from an external application, I'd probably use the REST API: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_delete_record.htm. The hardest part is implementing the oauth login. Take a look at this C# toolkit which handles all that for you: https://github.com/developerforce/Force.com-Toolkit-for-NET