本文实例讲述了PHP实现Soap通讯的方法。分享给大家供大家参考。具体实现方法如下:
代码如下:
0) {
$data = fread($fp,$dataLength);
}
fclose($fp);
if(strlen($data) != $dataLength || $dataLength <= 0) {
return FALSE;
}
return $data;
}
}
function ConstructData($namespace,$data) {
$soapData = "
\r\n";
$soapData .= "http://schemas.xmlsoap.org/soap/envelope/\">\r\n";
$soapData .= " \r\n";
$soapData .= " <$action xmlns=\"$namespace\">\r\n";
foreach($data as $name => $value) {
$name = iconv("GBK","UTF-8",$name);
$value= iconv("GBK",$value);
$soapData .= " <$name>$value$name>\r\n";
}
$soapData .= " $action>\r\n";
$soapData .= " \r\n";
$soapData .= " ";
return $soapData;
}
$data=array(
'user'=>'测试',//如果需要输入二进制数据请采用BASE64编码
'pass'=>'test'
);
echo HttpSoap('sample.anyhost.com',80,'/sampleSoap.asmx','http://tempuri.org/','logIn',$data);
?>
希望本文所述对大家的PHP程序设计有所帮助。
原文链接:https://www.f2er.com/php/23553.html