v2kea412 Posted July 15, 2009 Share Posted July 15, 2009 I have a need to synchronously communicate XML over HTTPS using POST. The originating server is using Java servlets to call my URL. I can see the XML payload in $HTTP_RAW_POST_DATA and can process what I need to do on my end just fine. Part of the synchronous transmission is to let the Java servlet that I received the XML just fine. My PHP code simply echo's back the XML response as such: if (isset($HTTP_RAW_POST_DATA)) { // Setup variables // $errors = array(); $act = new Activity(4,1); $xml = $HTTP_RAW_POST_DATA; $transaction = new xmlTransaction($xml, $act->Id); $transaction->writeXaction(); $xmlOut = $transaction->sendResponse(); // Send Header with payload header("Content-type: text/xml"); echo $xmlOut; } In my test environment, using cURL, I can retrieve the XML verifying the send, but on their end, they say they see nothing... It is almost as if they are expecting something to be sent back to them, but not sure how to accomplish that. Perhaps it is my ignorance of web services, but I think I am missing something.... Any ideas out there? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 15, 2009 Share Posted July 15, 2009 What does your cURL code look like? it should be something like: <?php $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml")); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); curl_exec($ch); ?> Quote Link to comment Share on other sites More sharing options...
v2kea412 Posted July 15, 2009 Author Share Posted July 15, 2009 Here is what my test environment client has, omitted purposely is the xml payload and url... //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch,CURLOPT_HTTPHEADER, array('Content-Type: text/xml')); curl_setopt($ch,CURLOPT_URL,$url); curl_setopt($ch,CURLOPT_POST,false); curl_setopt($ch,CURLOPT_POSTFIELDS,$xml); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //execute post $result = curl_exec($ch); echo $result; //close connection curl_close($ch); And like I said, this does show me what I thought they would see when called from their Java Servlet...But they say they are not receiving anything... The only other thing to note, and not sure if it would make a difference, is that I am also emailing the XML response to myself for debugging purposes in my listening script... Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 15, 2009 Share Posted July 15, 2009 use curl_setopt($ch, CURLOPT_POST, TRUE); you currently have it set to false edit: you may also want this: curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); just in case there is some redirect that happens Quote Link to comment Share on other sites More sharing options...
v2kea412 Posted July 15, 2009 Author Share Posted July 15, 2009 I believe I had the POST set to true in an earlier test. That said, my issue is not necessarily with my client-side test. I am more focused on what I have to do differently to get the acknowledgment back to them after I process the request. Here is the code of my listener: <?php require("trex.classes.inc.php"); if (isset($HTTP_RAW_POST_DATA)) { // Setup variables // $errors = array(); $act = new Activity(4,1); $xml = $HTTP_RAW_POST_DATA; $transaction = new xmlTransaction($xml, $act->Id); $transaction->writeXaction(); $xmlOut = $transaction->sendResponse(); // Send Header with payload header("Content-type: text/xml"); echo $xmlOut; sendRequest($transaction->raw, $xmlOut); unset($transaction); unset($act); } ?> Should I be using some other functions to get the $xmlOut to them? like HTTPResponse class or something similar? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.