php webservice 实现

WBOY
Release: 2016-06-20 13:00:46
Original
1113 people have browsed it

php webservice 实现

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;
}
Copy after login

PHP: SoapClient类 :

http://php.net/manual/en/class.soapclient.php


Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template