Friday 25 March 2016

Configure Salesforce for On demand Integration Using Dell Boomi


In this post I will give you example of invoking Boomi process using Apex class.

Invoke Boomi Atom

You require an End point URL to invoke your Boomi atom. Boomi atom could be a cloud atom or an on premises atom (locally deployed atom). Below example will explain how to connect with on premises atom.

Login your Boomi environment and click on "Atom Management".Navigate to "Shared Web Server Setting" and copy "Base URL" of your on premises atom along with port.


Salesforce Remote Site Setting

When ever you access any external site from Salesforce you need to add that in remote site setting. This is a security layer that force.com platform will check.
Enter base URL in remote site setting in your salesforce organization. 

Apex Class

Below example demonstrate that how we can pass some parameter to Dell Boomi interface in the form of an XML.

In my previous post we created "End point URL". 

Now we will use our end point url in apex class and call our Boomi process simply by writing below code.

Note: This is a generic XML structure.XML structure may differ on the bases of response profile you created in Boomi.

 public static HttpResponse getInfoBoomi()
    {
        // Get the Endpoint URL from custom label      
        String EndPointUrl = Endpoint URL;
        Httprequest request = new Httprequest();
        request.setmethod('POST');
        request.setTimeout(120000);

        request.setEndpoint(EndPointUrl);
        //set the request string for Boomi service connector containing Invoice No which will than pass to SAP to get the Invoice Base64 code
        string strInput = '<?xml version="1.0" encoding="UTF-8"?>' +
            '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
            '   <soapenv:Body> <setOutput xmlns="https://secure.logmeinrescue.com/API/API.asmx"> 
            '      <notifications xmlns="http://soap.sforce.com/2005/09/outbound">' +
            '         <Notification> ' +
            '               <InvoceId>' + ApexPages.currentPage().getParameters().get(ID) + '</InvoceId>' +
            '         </Notification>' +
            '      </notifications>' +
            '   </soapenv:Body>' +
            '</soapenv:Envelope>';

        //replace all & with &amp; to avoid xml encoding issue                      

        strInput = strInput.replaceAll('&', '&amp;');
        request.setBody(strInput);
        Http httprequest = new Http();
        string responseMessage;
        HttpResponse res;
        //send http request to boomi process
        res = httprequest.send(request);
        return res;


    }

By calling above mention function "getInfoBoomi" will provide you http response coming from your Boomi process.You can use built in function getbody to extract your data from response file.

HttpResponse res = getInfoBoomi();
 sData = res.getbody();

This way you can invoke your Boomi process from Salesforce. Hope this helps you !




1 comment:

  1. Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one......
    salesforce integration

    ReplyDelete