You need to sign in to do that
Don't have an account?
Recieving XML in Webservice using Rest architecture??
Hi,
I wrote a webservice which uses RestRequest to recieve the xml, however I am not able to convert the recieved request into xml i.e Dom.document or xmlstreamreader, below is the webservice I wrote, I able to see the xml in the log System.debug('--->RestContext.request'+req); but How do I convert RestContext.request to dom or xmlstreamreader, as I need to parse and create record from the data??, Thanks a lot
@RestResource(urlMapping='/CandExpJobPost_Router/v1/*')
global with sharing class CandExpJobPost_RouterV1 {
static boolean LogEvent = false;
CandExpJobPost_RouterV1(){System.debug('----->ssip');}
@HttpPost
global static String doRecieve( ) {
mydef doc3;
createjobpostfromxml parse=new createjobpostfromxml();
//System.debug('Recieved xml -->'+doc3);
RestRequest req = RestContext.request;
RestResponse res = RestContext.response;
String xml = req.requestBody.toString().trim();
System.debug('--->RestContext.request'+req);
System.debug('--->xml'+xml);
//res.addHeader('Content-Type', 'text/xml');
testdomjobpost testdoc = new testdomjobpost();
String x=String.Valueof(req);
}
Hi Kumarhatti,
Use XMLDom to Parse the response.
for example:
your XML response in debuglog is below
<Member>
<Name>rdinakaran</Name>
<TS>30000<TS>
</Member>
then use the following code to parse it and create a record.
Let me know if any issues, or if it works ,please mark it solved.
Thanks,
rdinakaran