note 64094 added to function.fsockopen

From: Date: Fri, 07 Apr 2006 09:09:25 +0000
Subject: note 64094 added to function.fsockopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-107503@lists.php.net to get a copy of this message
This is a simple example for sending and retrieve SOAP message by using fsockopen: <?php $fp = @fsockopen("www.example.com", 80, $errno, $errstr); if (!$fp) { echo "$errstr ($errno)<br />\n"; } else { $soap_out = "POST /example/exampleServer.php HTTP/1.0\r\n"; $soap_out .= "Host: www.example.com\r\n"; $soap_out .= "User-Agent: MySOAPisOKGuys \r\n"; $soap_out .= "Content-Type: text/xml; charset=ISO-8859-1\r\n"; $soap_out .= "Content-Length: 512\r\n\r\n"; $soap_out .= '<?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <ns5973:contact xmlns:ns5973="http://tempuri.org"> <__numeric_0><id xsi:nil="true"/></__numeric_0> </ns5973:contact> </SOAP-ENV:Body> </SOAP-ENV:Envelope>'; fputs($fp, $soap_out, strlen($soap_out)); // send request SOAP echo "<xmp>".$out."</xmp>"; while (!feof($fp)) { $soap_in . = fgets($fp, 100); } echo "<xmp>$soap_in</xmp>"; //display response SOAP fclose($fp); } ?> And this is an example result: POST /soap/example/contactServer.php HTTP/1.0 Host: www.example.com User-Agent: MySOAPisOKGuys Content-Type: text/xml; charset=ISO-8859-1 Content-Length: 512 <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body><ns5973:contact xmlns:ns5973="http://tempuri.org"><__numeric_0><id xsi:nil="true"/></__numeric_0></ns5973:contact> </SOAP-ENV:Body> </SOAP-ENV:Envelope> HTTP/1.1 200 OK Date: Thu, 06 Apr 2006 07:03:26 GMT Server: Apache/1.3.23 (Win32) X-Powered-By: PHP/4.1.1 X-SOAP-Server: MySOAPisOKGuys Content-Length: 625 Connection: close Content-Type: text/xml; charset=ISO-8859-1 <?xml version="1.0" encoding="ISO-8859-1"?> <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body><ns1:contactResponse xmlns:ns1="http://tempuri.org"> <return xsi:type="xsd:string"> </return> </ns1:contactResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> ---- Server IP: 202.158.56.242 Probable Submitter: 202.169.225.219 ---- X-Spam-Status: No, hits=3.8 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER, HTML_50_60 autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.fsockopen.php Edit -- http://master.php.net/note/edit/64094 Del: integrated -- http://master.php.net/note/delete/64094/integrated Del: useless -- http://master.php.net/note/delete/64094/useless Del: bad code -- http://master.php.net/note/delete/64094/bad+code Del: spam -- http://master.php.net/note/delete/64094/spam Del: non-english -- http://master.php.net/note/delete/64094/non-english Del: in docs -- http://master.php.net/note/delete/64094/in+docs Del: other reasons-- http://master.php.net/note/delete/64094 Reject -- http://master.php.net/note/reject/64094 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#107503) next »