我目前正在尝试通过 SOAP(不幸的是他们提供的唯一接口/协议)与 Web 服务交互。为了更轻松地使用他们的 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 后,我收到了很多新错误,例如:type X is already已定义或找不到目标命名空间的架构。我将此归因于我对 WSDL 文件结构的一般不理解。
非常感谢帮助。
我尝试将 WSDL 文件导入 Visual Studio 2017。
指向 WSDL 文件的链接http://demo.coveto.de/soap?wsdl
无效,因为响应是Content-Type:text/html; charset=UTF-8
. 内容类型必须是Content-Type:text/xml;charset=UTF-8
.
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);
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句