当前位置:Gxlcms > PHP教程 > php使用soap的例子

php使用soap的例子

时间:2021-07-01 10:21:17 帮助过:23人阅读

  1. $soap = new SoapServer($wsdl,$array);

2、SoapClient

  1. $soap = new SoapClient($wsdl,$array);

3、SoapFault

  1. $fault = new SoapFault($faultcode,$faultstring);

两种引用方式: 方式1,引入wsdl文件。 方式2,不使用wsdl文件。

以下的例子便是不使用wsdl文件的方式。

服务器端代码:

 "abcd")); 
$server->setClass("service"); 
$server->handle(); 
?> 

客户端代码:

 "http://localhost/interface/soap.php", 
"uri"      => "abcd",  //资源描述符服务器和客户端必须对应 
"style"    => SOAP_RPC, 
"use"      => SOAP_ENCODED 
   )); 

echo $soap->Add(1,2); 
}catch(Exction $e){ 
echo print_r($e->getMessage(),true); 
} 
?> 

人气教程排行