我正在尝试从远程服务器使用 SOAP 网络服务,wsdl 文件位于此处 http://ecolinthcm.pi-asp.de/logaserver/services/UsersService?wsdl
我一直与那里的开发人员保持联系,但他们一直告诉我它工作正常,所以他们帮不上什么大忙......
我正在使用这段小代码戳熊看它是否还活着:
$WSDL = "http://ecolinthcm.pi-asp.de/logaserver/services/UsersService?wsdl";
// the file_get_contents methods doesn't change the end result unfortunately
//$data = file_get_contents($WSDL);
//file_put_contents('./wsdl.xml',$data);
//$WSDL = './wsdl.xml';
$opts = array(
'http'=>array(
'user_agent' => 'PHPSoapClient'
)
);
$context = stream_context_create($opts);
$service = new SoapClient($WSDL,array('stream_context' => $context, 'cache_wsdl' => WSDL_CACHE_NONE));
$result = $service->ErmUserBean (array("UserID","Password","TargetUserID"));
print '<pre>';
var_dump($result);
print '</pre>';
如标题中所述,我收到此消息作为返回:
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't find < definitions > in 'WSDL file URI' in C:\Users\username\Documents\EasyPHP-DevServer-14.1VC11\data\localweb\projects\API\index.php:30 Stack trace: #0 C:\Users\username\Documents\EasyPHP-DevServer-14.1VC11\data\localweb\projects\API\index.php(30): SoapClient->SoapClient('WSDL file URI', Array) #1 {main} thrown in C:\Users\username\Documents\EasyPHP-DevServer-14.1VC11\data\localweb\projects\API\index.php on line 30
我已经阅读了大多数关于此错误的帖子,因此在我的 SOAP 请求中尝试了很多变体。我还编辑了我的 php.ini 文件,使行
extension=php_openssl.dll
出现没有“;” (评论)之前我可以阅读 here .
最佳答案
您收到的错误消息是正确的,因为您链接到的 WSDL 无效。您可以下载它并将其提供给 WSDL 验证器(例如 https://www.wsdl-analyzer.com/ ),您将看到它无效并失败并显示类似的验证消息。
WSDL 无效,因为某些命名空间是错误的。例如,WSDL 模式的命名空间不是 https://schemas.xmlsoap.org/wsdl/
也不是 https://www.w3.org/2001/XMLSchema
XML 模式的命名空间。正确的是 http://
而不是 https://
。
我修复了 namespace 并在此处上传了一个有效的 WSDL 文件:http://filebin.ca/2lByBlPAOvCu/ChangedUsersService.xml .您可以将它与我保存在这里的原始文件进行比较:http://filebin.ca/2lBxfIDsyDas/OriginalUsersService.xml并查看差异。
尝试使用我的 WSDL 文件。将它提供给在线验证器和您的代码,看看它是否有效。
关于php - SOAP 错误 : Parsing WSDL: Couldn't find <definitions> in,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37855365/