+ Start a Discussion
dmchengdmcheng 

Using web services for data import?

Hello.  I'm fairly new to the web services aspects of force.com.  I have a client with a PHP/MySQL e-commerce system.  He wants to push new customer info and new transactions in an XML file to Salesforce on a regular basis.

I thought the solution would be to create a web service that exposes a Dom.Document variable for the XML data.  However, I get an IDE error "can not have a WebService scope because its type is not valid."

I presume then the only way to do this is to define an object in the webservice and send my client the WSDL.  Instead of submitting an XML file, he'll have to  submit the data as the webservice object.

Am I on the right track with that?

Thanks

David

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

If you can, have them use the Enterprise.wsdl available in Setup > App Setup > Develop > API. As long as they can use the create() call to insert some objects, you can write triggers to manipulate the data as it is inserted. If that's too much to ask of the client, you can move the processing into Salesforce; give them the WSDL for the method, and have them use file_get_contents to read the file into a string, and pass the XML verbatim into the web service method. Once the string is received, you can use Apex Code's native XML reader to parse the file and perform whatever actions you need to.

All Answers

SuperfellSuperfell

If they're going to call a web service, they could just call the standard web services to insert data, no need for you to write your own, unless you want to do some intermin manipulation of the data they are sending.

dmchengdmcheng

Thanks for the reply Simon.  Yes I need to do some manipulation before the data is inserted.

sfdcfoxsfdcfox

If you can, have them use the Enterprise.wsdl available in Setup > App Setup > Develop > API. As long as they can use the create() call to insert some objects, you can write triggers to manipulate the data as it is inserted. If that's too much to ask of the client, you can move the processing into Salesforce; give them the WSDL for the method, and have them use file_get_contents to read the file into a string, and pass the XML verbatim into the web service method. Once the string is received, you can use Apex Code's native XML reader to parse the file and perform whatever actions you need to.

This was selected as the best answer
Pal2011Pal2011

Hi,

 

I'm very new to salesforce developement. I've same kind of requirement as you mentioned here. My client wants to  import accounts data, and I'm getting that data in XML format. I need to create accounts record by checking if that account exist or not, if not then I need to create new account in salesforce. I'm not sure what should I do in order to achieve this.

 

Can anyone please help me with some sample code.

 

Thanks in advance.

Amritesh SinghAmritesh Singh

HI all,

 

I have also same requirement,to insert Account,contact and Opportunity records coming from .net server as a xml string.

I am able to it,but before inserting i have to check if those account,contact n Opp. is existing in salesfore or not.If not,then insert.

 

I have done every thing and also achieve my goal,but my code is working for only small records that is coming from extenal server.Currently i am sending 30-30 information in  xml to sfdc and its working,but more than 30 records at a time causing prblm,giving

error System.LimitException: Too many SOQL queries: 101

bcs i m using SOQL for checking the existing Account,contact and Opportunity.

Error like

System.LimitException: Too many DML statements : 151

System.LimitException: Too many code statements: 200001

 

Also occuring for more than 30 as i m also inserting Account,contact and Opportunity if it is not existing,

 

If u know any other way to do this pls share the idea,cause i have to import large data at a time from external server.

 

Thanx in adv