首页 >后端开发 >php教程 >PHP调用WebService,调用webservice_PHP教程

PHP调用WebService,调用webservice_PHP教程

WBOY
WBOY原创
2016-07-12 09:03:22783浏览

PHP调用WebService,调用webservice

1.  环境配置

配置php.ini,把php_soap.dll前面的分号去掉,

配置完成,需要重启。

2.  PHP调用代码,如下

<?<span>php 
</span><span>try</span><span>
{
</span><span>$soap</span> = <span>new</span> SoapClient("http://网址/服务名.asmx?wsdl"<span>); 
<br />/*给参数</span>orderdata<span>赋值*/ <br /></span><span>$contact</span> = "参数值"<span>; <br /></span><span>$params</span> = <span>array</span><span>( </span>"orderdata" => <span>$contact</span>,<span> ); <br /><br /></span><span>$result</span> = <span>$soap</span>->服务方法名(<span>$params</span><span>); <br /></span><span>print_r</span>(<span>$result</span><span>); <br />} <br /><br /></span><span>catch</span> (<span>Exception</span> <span>$e</span><span>) { <br /></span><span>echo</span> 'Caught exception: ', <span>$e</span>->getMessage(), "\n"<span>; <br />} <br /></span>?>

效果如下:

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1081088.htmlTechArticlePHP调用WebService,调用webservice 1. 环境配置 配置php.ini,把php_soap.dll前面的分号去掉, 配置完成,需要重启。 2. PHP调用代码,如下 ? php try...
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn