gpt4 book ai didi

web-services - 尝试将 WSDL 导入 Visual Studio 2013 时出现循环引用错误

转载 作者:行者123 更新时间:2023-12-04 04:05:28 25 4
gpt4 key购买 nike

导入描述 SIRI web service 的 WSDL 文件时在 Microsoft Visual Studio 2013 中,出现错误:

Warning 5
Custom tool warning: Fault named FaultName in operation GetProductionTimetable cannot be imported. Unsupported WSDL, the fault message part must reference an element. This fault message does not reference an element. If you have edit access to the WSDL document, you can fix the problem by referencing a schema element using the 'element' attribute. C:\path\to\TransportationDemo\TransportationDemo\Service References\ServiceReference\Reference.svcmap 1

使用 a modified version of the WSDL, created by the Israeli Ministry of Transporation 时,它删掉了很多方法,我得到另一个错误(在其他错误中):

Warning 5
Custom tool warning: Cannot import wsdl:portType
Detail: An exception was thrown while running a WSDL import extension: System.ServiceModel.Description.XmlSerializerMessageContractImporter
Error: Group 'ServiceDeliveryBodyGroup' from targetNamespace='http://www.siri.org.uk/siri' has invalid definition: Circular group reference.
XPath to Error Source: //wsdl:definitions[@targetNamespace='http://new.webservice.namespace']/wsdl:portType[@name='SOAP-Port'] C:\path\to\TransportationDemo\TransportationDemo\Service References\ServiceReference1\Reference.svcmap 1

似乎有些元素定义出现在不止一个XSD中。所以我尝试使用 svcutil.exe 手动创建代理代码。我按依赖项所需的文件添加文件。起初,我可以选择添加哪个文件,siri.xsdsiri\siri_base-v1.3.xsd,因为它们都包含 的定义ServiceRequestStructure 元素。

siri.xsd 路径中,我添加了所有依赖项并以上述相同的循环引用结束。

siri\siri_base-v1.3.xsd 中,我实际上可以生成代码。我可以创建一个 SOAPPortClient 对象实例。我想对其调用 GetStopMonitoringServiceRequest 方法。但是为了能够输入必填字段,我需要一个 StopMonitoringRequestStructure 对象的实例。这在 siri_stopMonitoring_service.xsd 文件中定义,未包含在用于生成此代理的 XSD 列表中。当我确实添加这个架构文件时,我还必须添加siri_stopTimetable_service.xsd(用于定义MonitoringRefStructure),然后是循环依赖上面的错误消息再次出现。

我在这里不知所措,非常感谢在使用 Visual Studio 的 WSDL 方面有更多经验的人的帮助,或者只是一般的 SOAP 服务(或特别是这个服务),以解决这个问题。

请注意,SIRI 在两个单独的文件中提供 Web 服务接口(interface),siri_wsProducer.wsdlsiri_wsConsumer.wsdl。据我所知,我有兴趣与“制作人”互动。

这个问题是相关的——显然是一位开发人员提出的,如果他能参与这次讨论,我将不胜感激,因为他似乎已经找到了解决方案: Importing WSDL into a .NET project only creates an empty namespace

最佳答案

我对您的模式和 WSDL 进行了更多尝试,并找到了您问题的答案,尽管您可能不喜欢它...

  • unchecking the re-use types checkbox 没有区别,因为这仅适用于您重新导入定义的情况
  • 导入后,Visual Studio 将所有 XSD 置于服务引用下(单击“显示隐藏文件”)。选择 siri.xsd,它会告诉你它找不到两个包含。
  • 为了修复包含问题,我将包含 URI 更改为绝对 URI。这解决了 Visual Studio 无法找到文件然后正确复制它们的问题。
  • 现在重建时,它将在“调试输出”窗口中显示正确的验证错误。最重要的是,它提示重新定义。我通过删除对 xml.xsd 的任何引用并简化使用它的几个地方(仅 xml:lang)设法解决了这个问题。接下来我做的是将所有 XSD 直接放在根目录下,并修复 xsl:importxsl:include 中的所有引用以反射(reflect)这一点。许多重定义错误现在消失了
  • 它现在提示 xs:group 是循环的(它以前这样做过,但我希望其他警告不受影响):

    Microsoft.ServiceModel.targets(113,5): error : Group 'ServiceDeliveryBodyGroup' from targetNamespace='http://www.siri.org.uk/siri' has invalid definition: Circular group reference.

    这是一个棘手的问题,因为我没能追踪到为什么它被认为是圆形的,但如果是的话,this is allowed in XSD .它被导入了两次,但这似乎不是原因,我认为这是故意的。

进一步搜索后,似乎是微软的xsd.exe,它类似于wsdl.exesvcutil使用的代码并添加服务引用,已确认此 to be a limitation of their XSD-to-object mapping tools .

我认为最好的办法是采用该组并使其成为非循环的。之后,它应该接受有效的模式并继续。进口商提示 wsdl:portType 的事实并没有为您指明正确的方向。它提示说,因为它无法映射所有类型,这导致根本没有映射任何类型,之后 wsdl:portType 也是未知的,因此出现错误。

修复 ServiceDeliveryBodyGroup 类型后,上述其他步骤很可能会过时。其他错误实际上是警告,我相信微软无论如何都会忽略此类重新定义,并将“正常”进行。

关于web-services - 尝试将 WSDL 导入 Visual Studio 2013 时出现循环引用错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32510797/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com