Home >php教程 >php手册 >PHP calls WebService

PHP calls WebService

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-06 13:30:471588browse

1. Environment configuration Configure php.ini and remove the semicolon in front of php_soap.dll. The configuration is complete and needs to be restarted. 2. PHP calling code, as follows? php try { $soap = new SoapClient("http://website/service name.asmx?wsdl" ); /*Assign a value to the parameter orderdata*/ $contact = "Parameter value"; $ params = array ( "order

1. Environment configuration

Configure php.ini and remove the semicolon in front of php_soap.dll,

Configuration is complete and needs to be restarted.

2. PHP calling code, as follows

<?<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>?>

The effect is as follows:


Statement:
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