1. 环境配置 配置php.ini,把php_soap.dll前面的分号去掉, 配置完成,需要重启。 2. PHP调用代码,如下 ? php try { $soap = new SoapClient("http://网址/服务名.asmx?wsdl" ); /*给参数 orderdata 赋值*/ $contact = "参数值" ; $params = array ( "order
1. 环境配置
配置php.ini,把php_soap.dll前面的分号去掉,
配置完成,需要重启。
2. PHP调用代码,如下
<span style="color: #000000;">php </span><span style="color: #0000ff;">try</span><span style="color: #000000;"> { </span><span style="color: #800080;">$soap</span> = <span style="color: #0000ff;">new</span> SoapClient("http://网址/服务名.asmx?wsdl"<span style="color: #000000;">); <br>/*给参数</span>orderdata<span>赋值*/ <br></span><span style="color: #800080;">$contact</span> = "参数值"<span>; <br></span><span style="color: #800080;">$params</span> = <span style="color: #0000ff;">array</span><span>( </span>"orderdata" => <span style="color: #800080;">$contact</span>,<span> ); <br><br></span><span style="color: #800080;">$result</span> = <span style="color: #800080;">$soap</span>->服务方法名(<span style="color: #800080;">$params</span><span>); <br></span><span style="color: #008080;">PRint_r</span>(<span style="color: #800080;">$result</span><span>); <br>} <br><br></span><span style="color: #0000ff;">catch</span> (<span style="color: #0000ff;">Exception</span> <span style="color: #800080;">$e</span><span>) { <br></span><span style="color: #0000ff;">echo</span> 'Caught exception: ', <span style="color: #800080;">$e</span>->getMessage(), "\n"<span>; <br>} <br></span>?>
效果如下: