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? Link to comment https://forums.phpfreaks.com/topic/166102-java-php-webservice-issue/ 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); ?> Link to comment https://forums.phpfreaks.com/topic/166102-java-php-webservice-issue/#findComment-875967 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... Link to comment https://forums.phpfreaks.com/topic/166102-java-php-webservice-issue/#findComment-875972 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 Link to comment https://forums.phpfreaks.com/topic/166102-java-php-webservice-issue/#findComment-875980 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? Link to comment https://forums.phpfreaks.com/topic/166102-java-php-webservice-issue/#findComment-875990 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.