SOAP-ERROR: Parsing WSDL: Couldn't find <definitions> in

SOAP-ERROR: Parsing WSDL: Couldn't find <definitions> in

我正在尝试从远程服务器使用 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>';

如标题所述,我在 return 中收到此消息:

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

关于此错误,我阅读了大部分 post,因此在我的 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://.

我修复了名称空间并在此处上传了一个有效的 WSDL 文件:http://filebin.ca/2lByBlPAOvCu/ChangedUsersService.xml. You can compare it with the original file which I saved here: http://filebin.ca/2lBxfIDsyDas/OriginalUsersService.xml 并查看了差异。

尝试使用我的 WSDL 文件。将它提供给在线验证器和您的代码,看看它是否有效。