文档地址
https://econea.github.io/nusoap/
客户端代码示例
require_once('../lib/nusoap.php'); $proxyhost = isset($_POST['proxyhost']) ? $_POST['proxyhost'] : ''; $proxyport = isset($_POST['proxyport']) ? $_POST['proxyport'] : ''; $proxyusername = isset($_POST['proxyusername']) ? $_POST['proxyusername'] : ''; $proxypassword = isset($_POST['proxypassword']) ? $_POST['proxypassword'] : ''; echo 'You must set your username and password in the source'; exit(); $client = new nusoap_client("http://staging.mappoint.net/standard-30/mappoint.wsdl", 'wsdl', $proxyhost, $proxyport, $proxyusername, $proxypassword); $err = $client->getError();
server端代码示
require_once ("lib/nusoap.php"); $server = new soap_server (); // 避免乱码 $server->soap_defencoding = 'UTF-8'; $server->decode_utf8 = false; $server->xml_encoding = 'UTF-8'; $server->configureWSDL ('test'); // 打开 wsdl 支持 /* 注册需要被客户端访问的程序 类型对应值: bool->"xsd:boolean" string->"xsd:string" int->"xsd:int" float->"xsd:float" */ $server->register ( 'GetTestStr', // 方法名 array ("name" => "xsd:string" ), // 参数,默认为 "xsd:string" array ("return" => "xsd:string" ) ); // 返回值,默认为 "xsd:string" //isset 检测变量是否设置 $HTTP_RAW_POST_DATA = isset ( $HTTP_RAW_POST_DATA ) ? $HTTP_RAW_POST_DATA : ''; //service 处理客户端输入的数据 $server->service ( $HTTP_RAW_POST_DATA ); /** * 供调用的方法 * @param $name */ function GetTestStr($name) { return "Hello, { $name } !"; }