note 64094 deleted from function.fsockopen by cmb

From: Date: Sun, 07 Jul 2019 07:57:33 +0000
Subject: note 64094 deleted from function.fsockopen by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211503@lists.php.net to get a copy of this message
Note Submitter: yadiutama_skom at yahoo dot com ---- 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>

« previous php.notes (#211503) next »