You need to sign in to do that
Don't have an account?
DaveKemp
Can I process xml results doc from webservice callout?
Hi,
I've imported a wsdl and generated the classes into apex.
I can call the web service ok, but the webservice returns an xml doc with content dependant on what xml doc you send it in the first place.
Is there a way I can generically process the response rather than it expecting the results to map directly to salesforce classes?
Thanks,
David
Update:
So I finally got it to work by ditching the SOAP and just using a plain Http call as described here:
http://boards.developerforce.com/t5/General-Development/calling-WS-with-a-HTTP-request/td-p/483303
Thanks all
All Answers
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_xml_XmlStream_reader.htm
Regards,
Satish Kumar
Hi,
Thanks for your response, I'm now using the Http class to call out and process the response as detailed here:
http://boards.developerforce.com/t5/NET-Development/How-to-call-net-web-service-from-salesforce/td-p/134795/page/2
But, when I put my values in, I'm getting an error returned in the HttpResponse from the webservice:
[Status=Internal Server Error, StatusCode=500]
Server did not recognize the value of HTTP Header SOAPAction: http://xxx.xxx.xxx.xxx/MBSGPQueryServices
I thought the SOAPAction was basically the name of the function being called (i.e. MBSGPQueryServices), what am I missing?
Many thanks for any responses as this is driving me crazy!
Regards,
David
Code shown below:
Map<string,string> GPSXMLResponse = new Map<string,string>();
string xmlLength=string.valueof(xmlDoc.length());
HttpRequest req = new HttpRequest();
req.setEndpoint('http://xxx.xxx.xxx.xxx/MBSGPWebService/MBSGPService.asmx');
req.setMethod('POST');
req.setHeader('Content-Type', 'text/xml; charset=utf-8');
req.setHeader('SOAPAction', 'http://xxx.xxx.xxx.xxx/MBSGPQueryServices');
string b = '<?xml version="1.0" encoding="utf-8"?>';
b += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';
b += '<soap:Body>';
b += '<MBSGPQueryServices xmlns="http://xxx.xxx.xxx.xxx">';
b += '<ServiceDocType>' + xmlDoc + '</ServiceDocType>';
b += '</MBSGPQueryServices>';
b += '</soap:Body>';
b += '</soap:Envelope>';
System.debug('About to req.setBody(b):'+b);
req.setBody(b);
System.debug('After req.setBody(b):'+b);
Http http = new Http();
HTTPResponse res = http.send(req);
Update:
So I finally got it to work by ditching the SOAP and just using a plain Http call as described here:
http://boards.developerforce.com/t5/General-Development/calling-WS-with-a-HTTP-request/td-p/483303
Thanks all