+ Start a Discussion
Sridhar VenkateswaraluSridhar Venkateswaralu 

Response to the External System before Database Operation(REST SERVICE)

Hi All,

 

we have an application where Salesforce.com is connected to a .Net system through REST API.

Requirement:

1.) .NET System calls the Salesforce REST API and posts the Request as XML.

2.) Salesforce should receive the request as Class Object and acknowledge the external(>.NET) System saying 'Reached Salesforce'.

3.) Salesforce should start processing the request and then store in to the Database.

 

Issue: 

we are not able to send the response first to the external system and then start processing. response is sent only when the complete processing is done in Salesforce.

we tried with @future method, but it says that future methods cant accept the class objects as parameter.

 

Sample Code : 

 

@httpPost
    global static void receiveRequest(InnerClass.orderRequest orderRequest){       
           

RestResponse res = RestContext.response;           
res.headers.put('Content-Type','application/xml; charset=UTF-8');

res.responseBody = Blob.valueof('Reached Salesforce.');    

       

       //after this there is a call another method to perform processing of the request and database operation.

processRequest();

}

 

 

Is there any way in which we can achieve the requirement.