简体   繁体   中英

Transfer xml between two websites

I have a website which will act as a main store for all information and will have an SSL certificate. I then have about 10 satellite sites that need to periodically (from a cron script) but also on demand be able to exchange data between themselves and the main site. So basically the satellite site needs to be able to send data to the main data storage site, and the main data storage site needs to be able to send data to the satellite sites. I'm thinking XML as the data structure but I'm not sure how best to transport it, (SOAP, CURL etc) anyone have any ideas?

I was thinking maybe make an API that can be called with SOAP and transfer data in this way?

All the sites are PHP/MySql btw

does this sound like a good plan?

Any suggestions much appreciated thanks

This is a matter of opinion, but SOAP is almost certainly overkill in your situation. Just use regular HTTP GET and POST. The client should send name and value pairs indicating which information it needs, and send back the data in a format that's easy for you to parse in your client. If you're comfortable with XML use that. If JSON or even CSV work better for the type of data you're transmitting, use that instead. Generally speaking, I'd use the simplest approach that will work for your requirements, especially because you're not exposing the service to external users.

I would recommend following a RESTful architecture pattern. It leverages the existing HTTP protocol to handle resources. It sounds like you'd be doing read requests, so you'd just need to use the GET method. You could use a REST framework ( tonic is simple and should get the job done), or since GET's are so simple, just write it like a normal PHP request like serving up HTML to a browser.

(Of course, if this is just static data, you'd just need to drop the XML file in a public folder.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM