Hi,
I ma developing an API and i am using XML protocol to establish the communication channel between server and client.
I have developed the POC and it's working on my localhost. It send the XML data on server and server process it gives the response.
Client URL : http://localhost:8081/API/Client/
Server URL : http://localhost:8081/API/Server/
This Combination work very well
but , but when is change the Server URL to the real live server url then it not post the data on server, other way server not able ti received the data. In this URL is
Client URL : htttp://localhost:8081/API/Client/
Server URL : http://www.doman.com/API/Server/
And code at Client side is
$header[] = "Content-type: text/xml";
$options = array (
CURLOPT_HEADER => true ,
CURLOPT_HTTPHEADER => $header,
CURLOPT_URL => "http://www.domain.com/ASPI/Server/",
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $_p_SOAP,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_AUTOREFERER => true,
CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect
CURLOPT_TIMEOUT => 120, // timeout on response
CURLOPT_REFERER => "http://localhost:8081/API/Client/",
CURLOPT_FAILONERROR => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT']);
$curl = curl_init();
curl_setopt_array($curl, $options);
$response = curl_exec($curl);
curl_close($curl);
return $response;
and $_p_SOAP = "<request><product><productid>12345</productid><productid>12345</productid><productid>12345</productid><productid>12345</productid></product></request>"
and server code is
$xml = file_get_contents('php://input');
echo $xml."a" ;
$xml = new SimpleXMLElement($xml, LIBXML_NOCDATA, false);
echo $xml."sdfsdfds";
exit();
When process the code then it throw error
HTTP/1.1 301 Moved Permanently Date: Thu, 17 Sep 2009 00:45:47 GMT Server: Apache/2.2.3 (CentOS) Location: http://www.knoxed.com/estore/API/Server/ Content-Length: 323 Connection: close Content-Type: text/html; charset=iso-8859-1 HTTP/1.1 200 OK Date: Thu, 17 Sep 2009 00:45:48 GMT Server: Apache/2.2.3 (CentOS) X-Powered-By: PHP/5.1.6 Content-Length: 438 Connection: close Content-Type: text/html a
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /var/www/vhosts/knoxed.co.uk/httpdocs/estore/API/Server/index.php:11 Stack trace: #0 /var/www/vhosts/knoxed.co.uk/httpdocs/estore/API/Server/index.php(11): SimpleXMLElement->__construct('', 16384, false) #1 {main} thrown in /var/www/vhosts/knoxed.co.uk/httpdocs/estore/API/Server/index.php on line 11
THis error is say that, server is not received any data from client. That very strange.
Can any one help me on same ASAP.