Home  >  Article  >  Backend Development  >  PHP calls WebService, calls webservice_PHP tutorial

PHP calls WebService, calls webservice_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 09:03:22772browse

PHP calls WebService, calls webservice

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

The effect is as follows:

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1081088.htmlTechArticlePHP calls WebService, calls webservice 1. Configure the environment configuration php.ini, 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...
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