Inserting data from one server to another running PHP.
There is a simple way to accomplish the above-mentioned process, i.e., using web services. The logic behind a web service is very simple. A web service could be implemented by the exchange of data between a server and a client using SOAP, XML, or JSON.
First of all, implement a web service on the database side and then on the client side; both require authentication. A login username and password are required for accomplishing this. The most popular example of a web service is an RSS feed. All the data exchange is handled through the standard HTTP protocol using port 80, and the data is gotten from the server either in the form of XML or JSON. Below, I am giving a brief introduction to the web service technologies.
SOAP (Simple Object Access Protocol).
SOAP is a platform-independent, lightweight protocol for the exchange of information. SOAP is also a W3C recommendation. SOAP is basically an XML document, which is comprised of mainly three elements: an envelope, which checks the document to see if it is an XML document or not. a header element and the body, which actually contains the call and response information.
A SOAP request:
POST /InStock HTTP/1.1
Host: www.yoursite.com
Content-Type: application/soap+xml; charset=utf-8
// i recommend to specify the characterset encoding becuase windows based servers could also return sometime cp1252 encoding instead of utf-8
Content-Length: 111 // length of the content
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.mysite.com/soap_env" soap:encodingStyle="http://www.mysite.com/soap_enc">
<soap:Body xmlns:m="http://www.yoursite.com/student?soap">
<m:GetStudentFee>
<m:StudentName>Adam</m:StudentName>
</m:GetStudentFee>
</soap:Body>
</soap:Envelope>
{loadposition inart}
The SOAP response:
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: 111
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.mysite.com/soap_env"
soap:encodingStyle="http://www.mysite.com/soap_enc">
<soap:Body xmlns:m="http://www.yoursite.com/student?soap">
<m:GetStudentFeeResponse>
<m:Fee>34.5</m:Fee>
</m:GetStudentFeeResponse>
</soap:Body>
</soap:Envelope>
The preceding procedure can be made more secure by implementing authentication on the server side and connecting with curl on the client side.