转载请注明出处:http://blog.csdn.net/cwt0408/article/details/6952936
(谢谢合作!)
花了两天的时间熟悉WSDL:
基础教程:http://www.w3school.com.cn/wsdl/
转载请注明出处,谢谢合作!
环境:WAMP
1、打开php对SOAP模块的支持,只要在php.ini中将 extension=php_soap.dll 前面的“;”去掉,然后重启apache。
2、建立两个虚拟目录便于调试,并绑定域名。
(1)虚拟目录创建:
现在E盘建立两个目录,service和client
在wamp安装目录中顺着路径C:\wamp\bin\apache\Apache2.2.17\conf\extra,找到httpd-vhosts.conf
NameVirtualHost 10.0.18.145:80 <VirtualHost 10.0.18.145:80> ServerName www.mysoapclient.cn ServerAlias mysoapclient.cn DocumentRoot e:/client </VirtualHost> <VirtualHost 10.0.18.145:80> ServerName www.mysoapservice.cn ServerAlias mysoapservice.cn DocumentRoot e:/service </VirtualHost>
<Directory "E:/client/"> Options Indexes FollowSymLinks AllowOverride all Order Allow,Deny Allow from all </Directory> <Directory "E:/service"> Options Indexes FollowSymLinks AllowOverride all Order Allow,Deny Allow from all </Directory>
10.0.18.145 www.mysoapclient.cn 10.0.18.145 www.mysoapservice.cn
<?php echo "Create OK!" ?>
<?php function GetInfo(){ return date('Y-m-d'); } $soap=new SoapServer(null,array('uri'=>"http://www.mysoapservice.cn/service.php")); $soap->addFunction('GetInfo'); $soap->handle(); ?>
<?php header('Content-Type:text/html;charset=utf-8'); try { $soap = new SoapClient(null,array('location'=>'http://www.mysoapservice.cn/service.php','uri'=>'http://www.mysoapservice.cn/service.php')); echo $soap->GetInfo()."<br>";//调用方法一 echo $soap->__soapcall("GetInfo",array());//调用方法二 }catch(SoapFault $e){ echo "Soap error ".$e->getMessage(); }catch(Exception $e){ echo "Exception error ".$e->getMessage(); } ?>