且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2021-11-20 21:59:56

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

I have played a little more with your schemas and WSDL and found an answer to your issue, although you may not like it...

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

  • There is no difference in unchecking the re-use types checkbox, because that only applies to situations where you re-import the definitions
  • After import, Visual Studio places all XSD's under the service reference (click "show hidden files"). Select siri.xsd and it will show you that it cannot locate two includes.
  • To fix the include-issue, I changed the include URI to an absolute URI. This resolved the issue with Visual Studio not being able to locate the files and it then copies them properly.
  • When now rebuilding, it will show in the Debug Output window the proper validation errors. Most importantly, it complains about redefinitions. I managed to resolve this by removing any reference to xml.xsd and simplifying the few places where it was used (xml:lang only). Next thing I did was to place all XSD's directly under the root and fixed all references in xsl:import and xsl:include to reflect this. Many redefinition errors now disappeared
  • It now complains about an xs:group being circular (it did so before, but I wanted other warnings to be out of the way):

Microsoft.ServiceModel.targets(113,5):错误:来自 targetNamespace=' 的ServiceDeliveryBodyGroup"组http://www.siri.org.uk/siri' 的定义无效:循环组引用.

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

这是一个棘手的问题,因为我没有设法追踪为什么它被认为是循环的,但如果是,这在 XSD 中是允许的.它被导入了两次,但这似乎不是原因,我认为这是故意的.

This is a tricky one, because I didn't manage to track why it is considered circular, but if it is, this is allowed in XSD. It gets imported twice, but that does not seem to be the cause, I think this is deliberate.

进一步搜索后,似乎是微软的xsd.exe,与wsdl.exesvcutil使用的代码类似并添加服务引用,已确认此限制了他们的 XSD 到对象映射工具.

After some further searches, it appears that Microsoft's xsd.exe, which is similar to the code used by wsdl.exe, svcutil and add a service reference, has acknowledged this to be a limitation of their XSD-to-object mapping tools.

我认为你***的办法是把那个小组变成非圆形.之后,它应该接受模式为有效并继续.进口商抱怨 wsdl:portType 的事实并没有为您指明正确的方向.它抱怨说,因为它无法映射所有类型,导致根本没有映射任何类型,之后 wsdl:portType 也是未知的,因此错误.

I think your best bet is to take that group and make it non-circular. After that, it should accept the schemas as valid and proceed. The fact that the importer complains about wsdl:portType does not point you in the right direction. It complains about that, because it fails to map all types, which results in mapping no types at all, after which also wsdl:portType is unknown, hence the error.

修复 ServiceDeliveryBodyGroup 类型后,上述其他步骤很可能会过时.其他错误实际上是警告,我相信 Microsoft 基本上会忽略此类重新定义,并将正常"进行.

It is very well possible that the other steps outlined above become obsolete after you fix the ServiceDeliveryBodyGroup type. The other errors were actually warnings, and I believe that Microsoft essentially ignores such redefinitions anyway and will proceed "normally".