php webservice 实现
其实要注意的就这两点:
调用的函数如果要传参,参数一定要写在一个array里;
传入的参数数组的键值对中,键值一定要与wsdl里描述的参数的name属性一致,eg:例子中的'in0'。
//自己项目中用到的测试webservice代码,拿来当例子了 try { $wsdl = "http://111.1.14.10/webservice/services/deliver?WSDL"; $client = new SoapClient($wsdl); //var_dump($client->__getFunctions()); //echo "<br/>"; //var_dump($client->__getTypes()); //echo "<br/>"; $corporation = "something"; $params = array( 'in0' => $corporation ); $result = $client->deliver($params); //var_dump($result); $result = json_encode($result); //echo htmlspecialchars($result); } catch (SOAPFault $e) { echo $e; }
PHP: SoapClient类 :
http://php.net/manual/en/class.soapclient.php