开发者

fsockopen soap request

开发者 https://www.devze.com 2022-12-28 06:11 出处:网络
I am trying to send a SOAP messag开发者_Go百科e to a service using php. I want to do it with fsockopen, here\'s is the code :

I am trying to send a SOAP messag开发者_Go百科e to a service using php.

I want to do it with fsockopen, here's is the code :

<?php

$fp = @fsockopen("ssl://xmlpropp.worldspan.com", 443, $errno, $errstr);

if (!is_resource($fp)) { die('fsockopen call failed with error number ' . $errno . '.' . $errstr); }

$soap_out = "POST /xmlts HTTP/1.1\r\n"; $soap_out .= "Host: 212.127.18.11:8800\r\n"; //$soap_out .= "User-Agent: MySOAPisOKGuys \r\n"; $soap_out .= "Content-Type: text/xml; charset='utf-8'\r\n"; $soap_out .= "Content-Length: 999\r\n\r\n"; $soap_put .= "Connection: close\r\n"; $soap_out .= "SOAPAction:\r\n"; $soap_out .= ' Worldspan This is a test ';

if(!fputs($fp, $soap_out, strlen($soap_out)))
    echo "could not write";
echo "<xmp>".$soap_out."</xmp>";
echo "--------------------<br>";

while (!feof($fp)) 
{
    $soap_in .= fgets($fp, 100);
}

echo "<xmp>$soap_in</xmp>";   

fclose($fp);
echo "ok";

the above code just hangs . if i remove the while it types ok, so i suppose the problem is at $soap_in .= fgets($fp, 100)

Any ideas of what is happening


Its not just a matter of opening a socket then writing 'POST....' to it - you need a full HTTP stack to parse the possible responses (e.g. what different encodings? Partial Content?). Use cURL.

The reason its currently failing is probably because the remote system is configured to use keepalives - which would again be solved by using a proper HTTP stack.

C.


I recommend, use curl for soap actions. http://www.zimbra.com/forums/developers/9890-solved-simple-soap-admin-example-php.html#post52586

0

精彩评论

暂无评论...
验证码 换一张
取 消