+ Start a Discussion
Daniel B ProbertDaniel B Probert 

External xml import

Hi All,


I have an external webservice that I am looking to pull data from in salesforce as a batch process. 


at the moment if I run the following command I get an xml response


curl -X POST -d "username=test@test.com&accesstoken=djkfdjfdkfjdklfjdlk" https://webserver/api/surveys


this will give me an output of






Ideally I would want to take this xml file and then populate an object called forms with the surveyid and the surveyname, with the surveyid being the unique reference.


any guidance would be appreciated.






Well, you call the external webservice from Apex using Apex Callouts.
Once you get the XML file, you use the XMLStreamReader class to parse the xml. Based the parse data you write apex code to populate the objects.

Link: http://developer.force.com/cookbook/recipe/parsing-xml-using-the-apex-dom-parser

Reference: http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content/apex_System_XmlStreamReader_instance_methods.htm?CSHID=apex_System_XmlStreamReader_instance_methods.htm

Satish Kumar
And here is some information on Apex Callouts.


Satish Kumar