Simply use nusoap to call the webservice

WBOY
Release: 2016-07-28 08:29:05
Original
1374 people have browsed it

Use PHP to call webservice. There is a very convenient encapsulation class nusoap, which can be downloaded at http://sourceforge.net/projects/nusoap/files/.

The use of NuSOAP is relatively simple. The most commonly used classes are soap_server and soapclient. The soap_server is used to create Webservice services, and the soapclient class is used to call Webservice. The definitions of these two classes are in lib/nusoap.php , so we need to reference this file when creating or calling the Webservice interface program.

require('lib/nusoap.php');

// $xml = '一段XML标签,由webservice的server端来规定,一般在接口文档里可以看到';

// $soapClient = new nusoap_client("webservice的调用地址",TRUE); //TRUE参数表示使用wsdl
// $soapClient->xml_encoding = 'UTF-8'; //指定字符编码
// $soapClient->soap_defencoding = 'UTF-8';

// $parameters = array("参数1"=>"", "参数2"=>$xml); //参数也需要根据接口文档来写
// $outString = $soapClient->call("方法名", $parameters);

// var_dump($outString);
Copy after login

The above has introduced how to simply use nusoap to call webservice, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!