php soap扩展简单对象访问协议是交换数据的一种协议规范,是一种轻量的、简单的、基于XML(标准通用标记语言下的一个子集)的协议,它被设计成在WEB上交换结构化的和固化的信息,下面我们来看看小编整理的php soap扩展开启与__soapCall使用问题
例子
try {
$client = new SoapClient("http://localhost:8080/Webtest/NewService?wsdl");
// $result = $client->__soapCall("operation",array(4));//fault
// $result = $client->__soapCall("operation",array("id"=>4));//fault
// $result = $client->operation(4);//fault
$result = $client->operation(array("id"=>4));//OK
$back = json_encode($result);
echo $back;
} catch (SoapFault $fault){
echo "Error: ",$fault->faultcode,", string: ",$fault->faultstring;
}
?>
//仅有标记为OK的那行可以成功返回数字4,其它返回的都是数字0(参数应该是没有传过去,服务器端id初始是0)。
//手册里soapcall的例子:
$client = new SoapClient("some.wsdl");
$client->SomeFunction($a, $b, $c);
$client->__soapCall("SomeFunction", array($a, $b, $c));
$client->__soapCall("SomeFunction", array($a, $b, $c), NULL,
new SoapHeader(), $output_headers);
$client = new SoapClient(null, array('location' => "http://localhost/soap.php",
'uri' => "http://test-uri/"));
$client->SomeFunction($a, $b, $c);
$client->__soapCall("SomeFunction", array($a, $b, $c));
$client->__soapCall("SomeFunction", array($a, $b, $c),
array('soapaction' => 'some_action',
'uri' => 'some_uri'));
?>