PHP 的 SOAP client 调用 的 WSDL 模式失败,non-WSDL 模式成功。
在Solaris 10操作系统,PHP5.2.4的版本,写一个 SOAP client 的php程序,用 soapclient 的WSDL模式调用服务器的wsdl文件失败,但是用 non-WSDL模式调用 服务器的 soap-action程序却成功了,有人知道为什么?
程序如下采用 WSDL 模式:
<?php
$client = new SoapClient("http://server_path/inventory.wsdl";
$return = $client->getItemCount('23489');
print_r($return);
?>
总是出现错误:
Warning: SoapClient::SoapClient(): I/O warning : failed to load external entity "http://server_path/inventory.wsdl" in /export/home/client-test.php on line 8
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from 'http://server_path/inventory.wsdl' in /export/home/client-test.php:8
Stack trace:
#0 /export/home/client-test.php(: SoapClient->SoapClient('http://server_path')
#1 {main}
thrown in /export/home/client-test.php on line 8
如果改为 non-WSDL 模式,则成功了,程序如下:
<?php
$client = new SoapClient(null,array('location'=>'http://server_path'/server.php',uri => 'server.php'));
$return = $client->getItemCount('23489');
print_r($return);
?>
上面的 server.php 就是 inventory.wsdl 指定的soap action的程序 名字。
也就是说,在 php 的 soapclient 采用 wsdl 模式调用 服务器的 wsdl 失败,但是 采用 non-wsdl 模式调用 服务器的 php 程序就是成功,有没有兄弟知道为什么?