You need to sign in to do that
Don't have an account?

How to Get XML Response from the FUTURE Callout and Read the XML Response in other method?
Hi,
Can anyone help me in this. want to get the XML response from future callout and read it from other method. please look into sample code of mine.
@future(callout=true)
public static void calloutsample(string name,String phone)
{
http h=new http();
tring endPointURL='https://www.endpoint.com';
Http req = new Http();
HttpRequest Req=new HttpRequest();
Req.setHeader('Content-Length', '0');
Req.setEndpoint(endPointURL);
Req.setMethod('POST');
Req.setHeader('Content-Type',text/XML) // Is this correct, i am sending xml data to external system
Req.setbody(XMLString);
httpresponse res=h.send(Req);
xmlStreamReader reader=res.getxmlStreamReader();
readresponse(reader); //Is this correct. this is the method to read the xml response
}
public void readresponse(reader)
{
//want to read the xml response here, based on the response want to perform some actions.
}
Can anyone help me in this. want to get the XML response from future callout and read it from other method. please look into sample code of mine.
@future(callout=true)
public static void calloutsample(string name,String phone)
{
http h=new http();
tring endPointURL='https://www.endpoint.com';
Http req = new Http();
HttpRequest Req=new HttpRequest();
Req.setHeader('Content-Length', '0');
Req.setEndpoint(endPointURL);
Req.setMethod('POST');
Req.setHeader('Content-Type',text/XML) // Is this correct, i am sending xml data to external system
Req.setbody(XMLString);
httpresponse res=h.send(Req);
xmlStreamReader reader=res.getxmlStreamReader();
readresponse(reader); //Is this correct. this is the method to read the xml response
}
public void readresponse(reader)
{
//want to read the xml response here, based on the response want to perform some actions.
}
Then you just call it the same way you are above.
You setHeader is close but you'll want
The content type should be all lower case.
All Answers
Then you just call it the same way you are above.
You setHeader is close but you'll want
The content type should be all lower case.
here Iam having one more doubt, can we pass colletion of callections in future callout method.
for example :
@future(callout=true)
public static void calloutsample(string name,String phone,map<String,map<string,string>> mapvalues)
(OR)
@future(callout=true)
public static void calloutsample(string name,String phone,map<map<string,string>,<String,string>> mapvalues)
In my mapvalues am storing request values and want to save transaction data(request) it into salesforce object but it is not supporting. can you give any idea on this.
[1] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm#apex_System_Json_serialize
[2] https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_System_Json.htm#apex_System_Json_deserializeUntyped