I've been toying around with something over the last few days but can't quite get it to work. Wondering if anyone can help me.
I have a Java servlet running on Tomcat (this is all on my local machine for testing purposes). This servlet accepts one variable (a block of XML) and returns another block of XML as a result. The servlet is running fine (I can test it through my browser and even POST successfully to it from a PHP form receiving the correct XML block as result). What I want to be able to do post the data and access the result with curl.
Here is my current code -
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost:8080/myServer/TestServlet
curl_setopt($ch, CURLOPT_POST, 1 );
curl_setopt ($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$postResult = curl_exec($ch);
$xmlResult = file_get_contents($postRes
I want to be able to read $xmlResult. Everytime I try to run this, I get an error message that the posted data is empty. What am I doing wrong? Is there an alternative to curl that I could be using?
Thanks in advance