最近需要打一个php soap webservice 写了个测试的demo 代码非常简单
网上也看了不少教程 碰到一个棘手的问题
服务端 service.php
<?phpclass service{ public function HelloWorld() { return "Hello"; } public function Add($a,$b) { return $a+$b; }}$server=new SoapServer('TestSoap.wsdl',array('soap_version' => SOAP_1_2));$server->setClass("service");$server->handle();?>
<?php//$soap = new SoapClient("http://localhost/web/TestSoap.wsdl", array('soap_version' => SOAP_1_2));$soap = new SoapClient("TestSoap.wsdl", array('soap_version' => SOAP_1_2));echo $soap->Add(1,6);echo $soap->HelloWorld()."<br />";?>
$soap = new SoapClient("http://localhost/web/service.php?wsdl", array('soap_version' => SOAP_1_2));
第二个参数可以不要
$soap = new SoapClient("http://localhost/web/service.php?wsdl", array('soap_version' => SOAP_1_2));
第二个参数可以不要
第二个参数删了结果还是一样
看看你的wsdl文件的soap:address返回的地址端口是否正确的
WSDL-Endpoint:
我也遇到这个问题,求解答。