ChrisScott Posted May 20, 2008 Share Posted May 20, 2008 Hi. Thanks in advance for any help... I am writing a web service which receives a SOAP over HTTP message. It then goes and retrieve some information from a different web service using the data received at the beginning. <?php $fd = fopen('PMS_IN.log', 'a'); if(isset($GLOBALS['HTTP_RAW_POST_DATA']) && strlen($GLOBALS['HTTP_RAW_POST_DATA'])>0) { $pms_req = new DOMDocument(); $pms_req->preserveWhiteSpace = false; $pms_req->loadXML($GLOBALS['HTTP_RAW_POST_DATA']); $pms_req_xpath = new DOMXPath($pms_req); $pms_req_urls = $pms_req_xpath->query("/soap:Envelope/soap:Body"); foreach ( $pms_req_urls as $url ) { fwrite($fd, $url->firstChild->data . "\r\n"); $asset_data = fopen($url->firstChild->data,"r"); //this is opening the URL if (!$asset_data) { $errormessage = error_get_last(); foreach ($errormessage as $err ) { fwrite($fd, "ERROR FROM FOPEN IS: $err \r\n"); } } else { while (!feof($asset_data)) { $mmwsi_xml = $mmwsi_xml . htmlspecialchars(fgets($asset_data, 64)); } fclose($asset_data); } fwrite($fd, $mmwsi_xml); ... ... ... The fopen is returning a "HTTP/1.1 500 Internal Server Error" from the second web service due to the fact that the URL it tries to open has encoded ampersands. The second web service is logging amp;var=content as arguments from the URL. I have tested this using explicit urls: fine with no & and error with. Basically I need fopen to open "http://ip/webservice?service=a&arg=b" literally but it will try to open "http://ip/webservice?service=a&arg=b". Any ideas would be much appreciated. Link to comment https://forums.phpfreaks.com/topic/106514-fopen-encoding-ampersands-causes-a-http-500-error/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.