将 PHP 生成的 WSDL 导入 Visual Studio 2017

Importing a PHP generated WSDL into Visual Studio 2017

我目前正在尝试通过 SOAP 与 Web 服务交互(不幸的是,他们提供的唯一 interface/protocol)。为了更轻松地使用他们的 Web 服务,他们提供了一个 WSDL,可以在此处查看:http://demo.coveto.de/soap?wsdl(它被标记为内容类型 text/html 而不是 application/soap+xml,它让它看起来很奇怪而且 VS 不会接受它,所以它必须保存到本地文件)。

我在将上述 WSDL 导入 Visual Studio 2017 时遇到问题。据我所知,推荐的方法是添加 WSDL(URL 或本地文件)作为服务参考,我做到了。这会在 VS17 中弹出以下我不清楚的错误:

Warning     Custom tool warning: Cannot import wsdl:binding
Detail: There was an error importing a wsdl:portType that the wsdl:binding is dependent on.
XPath to wsdl:portType: //wsdl:definitions[@targetNamespace='https://demo.coveto.de/soap']/wsdl:portType[@name='coveto_soapWebservicePort']
XPath to Error Source: //wsdl:definitions[@targetNamespace='https://demo.coveto.de/soap']/wsdl:binding[@name='coveto_soapWebserviceBinding']    

Warning     Custom tool warning: Cannot import wsdl:port
Detail: There was an error importing a wsdl:binding that the wsdl:port is dependent on.
XPath to wsdl:binding: //wsdl:definitions[@targetNamespace='https://demo.coveto.de/soap']/wsdl:binding[@name='coveto_soapWebserviceBinding']
XPath to Error Source: //wsdl:definitions[@targetNamespace='https://demo.coveto.de/soap']/wsdl:service[@name='coveto_soapWebserviceService']/wsdl:port[@name='coveto_soapWebservicePort']

Warning     Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter
Error: The datatype 'http://schemas.xmlsoap.org/soap/encoding/:Array' is missing.
XPath to Error Source: //wsdl:definitions[@targetNamespace='https://demo.coveto.de/soap']/wsdl:portType[@name='coveto_soapWebservicePort']  

(请注意,虽然它说的是警告,而不是错误,但有一个实际的错误,只是检查其他警告而已)

我认为只有最后一个实际上是问题,其他两个只是由它引起的。

我对 SOAP 或 WSDL 知之甚少,所以我无法准确指出问题所在。我尝试下载警告中提到的模式,但在各个地方或所有地方用文件名(与 wsdl 文件相同的目录)替换 URL 后,我收到很多新错误,例如:类型 X 已定义或找不到具有目标命名空间的架构。我将此归因于我对 WSDL 文件结构的一般不了解。

非常感谢您的帮助。

我已尝试将 WSDL 文件导入 Visual Studio 2017。

  1. WSDL 文件 http://demo.coveto.de/soap?wsdl 的 link 无效,因为响应是 Content-Type:text/html; charset=UTF-8。内容类型必须是 Content-Type:text/xml;charset=UTF-8.

  2. PHP 内部 SoapClient 不是很好。尝试改用 Zend SoapClient

这对我有用:

<?php

// composer require zendframework/zend-soap

require_once __DIR__ . '/vendor/autoload.php';

$client = new Zend\Soap\Client("http://demo.coveto.de/soap?wsdl");
$result1 = $client->getFunctions();
var_dump($result1);