Php 无法从webservice获取数据

Php 无法从webservice获取数据,php,web-services,Php,Web Services,以下是我的Web服务从dataclass(registerCustomer和getCountries)调用2个方法: 要调用web服务,请尝试以下操作: try{ $service = "http://example.org/myWebService.wsdl"; $client = new SoapClient($service, array('location' =>"http://example.org/myWebService")); $parameter1

以下是我的Web服务从dataclass(registerCustomer和getCountries)调用2个方法:


要调用web服务,请尝试以下操作:

try{
    $service = "http://example.org/myWebService.wsdl";
    $client = new SoapClient($service, array('location' =>"http://example.org/myWebService"));
    $parameter1 = new myWebServiceParameter();
    $result = $client->myWebServiceFunction($parameter1);
} catch (Exception $e) {
    // handle errors
}
您必须提供web服务端点的URL,而不是wsdl。myWebServiceParameter必须是具有相同名称的每个WSDL消息属性的成员变量的任何类。 myWebServiceFunction是web服务方法的名称

对于您的web服务,它可以是:

try{
    $service = "http://localhost/dataobjects/myWebservice.wsdl";
    $client = new SoapClient($service, array('location' =>"http://localhost/dataobjects/myWebservice"));
    $result = $client->getCountries();
} catch (Exception $e) {
    // handle errors
}

按您告诉我的那样尝试:try{$service=”“;$dataobj=new SoapClient($service,array('location'=>);$dataset=$dataobj->getCountries();}catch(Exception$e){echo$e;}现在它给了我另一个错误:SoapFault Exception:[Client]C:\Program Files\xamplite\htdocs\testingpage.php中的SOAP不支持DTD:13堆栈跟踪:#0[内部函数]:SoapClient->u调用('getCountries',数组)#1C:\Program Files\xamplite\htdocs\testingpage.php(13):SoapClient->getCountries()#2{main}您不能使用DTD来验证XML消息,而必须使用XML模式(或不使用).
try{
    $service = "http://example.org/myWebService.wsdl";
    $client = new SoapClient($service, array('location' =>"http://example.org/myWebService"));
    $parameter1 = new myWebServiceParameter();
    $result = $client->myWebServiceFunction($parameter1);
} catch (Exception $e) {
    // handle errors
}
try{
    $service = "http://localhost/dataobjects/myWebservice.wsdl";
    $client = new SoapClient($service, array('location' =>"http://localhost/dataobjects/myWebservice"));
    $result = $client->getCountries();
} catch (Exception $e) {
    // handle errors
}