【发布时间】:2011-10-02 23:17:42
【问题描述】:
我正在尝试使用 SDK 中的 SVCUTIL 来生成多个 Web 服务中的常用类型。当我尝试生成代码时,我得到了错误(显示在底部)——这些表明 WSDL 已损坏。但是,如果我在 ServiceReferences 中导入服务,Visual Studio 不会抱怨。 SVCUTIL 坏了吗?
WSDL 是公开的,并且是:
http://test.wlr3.net/empws/services/WLR3AssuranceServices?wsdl
http://test.wlr3.net/empws/services/WLR3BillingServices?wsdl
http://test.wlr3.net/empws/services/WLR3DialogueServices?wsdl
http://test.wlr3.net/empws/services/WLR3FulfillmentServices?wsdl
http://test.wlr3.net/empws/services/WLR3InventoryServices?wsdl
http://test.wlr3.net/empws/services/WLR3InventoryOrderServices?wsdl
http://test.wlr3.net/empws/services/WLR3InventoryTroubleReportServices?wsdl
http://test.wlr3.net/empws/services/WLR3InventoryWorkItemServices?wsdl
http://test.wlr3.net/empws/services/WLR3IssueServices?wsdl
http://test.wlr3.net/empws/services/WLR3ReportingServices?wsdl
http://test.wlr3.net/empws/services/WLR3SecurityServices?wsdl
如果您查看这些内容,您会看到很多常见类型和多个命名空间。我尝试将这些发送到 SVCUTIL 以生成代码,但它不喜欢 FulfillmentServices 和 InventoryServices 的:
Error: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter
Error: Cannot import invalid schemas. Compilation on the XmlSchemaSet failed.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://imperatives.co.uk/V20']/wsdl:portType[@name='WLR3FulfilmentServices']
Error: 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='http://imperatives.co.uk/V20']/wsdl:portType[@name='WLR3FulfilmentServices']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://imperatives.co.uk/V20']/wsdl:binding[@name='WLR3FulfillmentServicesHttpBinding']
Error: 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='http://imperatives.co.uk/V20']/wsdl:binding[@name='WLR3FulfillmentServicesHttpBinding']
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://imperatives.co.uk/V20']/wsdl:service[@name='WLR3FulfillmentServices']/wsdl:port[@name='WLR3FulfillmentServicesHttpPort']
【问题讨论】:
-
您使用的是什么版本的 .NET?第一个对我有用。
-
在这种情况下,它的目标是 3.5,因为库是共享的。 WSDL 可以很好地导入 Visual Studio,这是使用 SVCUTIL 获取类型的问题
-
我应该指出,似乎只有 Inventory 和 Fulfillment WSDL 会产生错误
-
我想我可能已经发现了原因。 InventoryServices 和 FulfilmentServices 的类型中有一个空的虚拟基本类型“Dto”。它只出现在这两个 wsdl 中,它们是在 SVCUTIL 中产生错误的。 WSDL 是有效的,所以我认为这是一个错误。将确认编辑这些结果是否会产生工作代码。
标签: wsdl svcutil.exe