简体   繁体   English

/ sharedtypes等效于svcutil.exe?

[英]/sharedtypes equivalent for svcutil.exe?

Building an app that is relying on a 3rd party provider who has a very verbose set of SOAP services (we're talking 50+ WSDL files). 构建一个依赖于第三方提供商的应用程序,该提供商拥有非常冗长的SOAP服务(我们正在讨论50多个WSDL文件)。 Each individual WSDL however has numerous shared type declarations. 但是,每个单独的WSDL都有许多共享类型声明。 When generating client code with wsdl.exe, there used to be a /sharedtypes flag that would merge duplicate entries if a type was found several times. 使用wsdl.exe生成客户端代码时,曾经有一个/ sharedtypes标志,如果多次找到类型,它将合并重复的条目。

When I attempt to generate my client code, I bomb on these overlapping types that the 3rd party includes in all their WSDL files. 当我尝试生成我的客户端代码时,我会轰炸第三方在其所有WSDL文件中包含的这些重叠类型。

svcutil /t:code /importxmltypes [mypath]/*.wsdl

Results in error messages alluding to the type collisions. 导致错误消息导致类型冲突。 For example, a couple samples of the error messages below: 例如,以下错误消息的几个示例:

Error: There was an error verifying some XML Schemas generated during export:
The simpleType 'http://common.soap.3rdparty.com:CurrencyNotation' has already been
declared.

Error: There was an error verifying some XML Schemas generated during export:
The complexType 'http://common.soap.3rdparty.com:NumberFormat' has already been 
declared.

I do not have control over the output of the WSDLs. 我无法控制WSDL的输出。 I do not want to have to edit the WSDLs by hand for fear of an error that breaks in a fashion at runtime that would be highly difficult to track back to our editing of the WSDL files. 我不想手动编辑WSDL,因为担心在运行时以某种方式破坏的错误很难追溯到我们编辑WSDL文件。 Not to mention that there are 50 some WSDL files that range from 200-1200 lines of XML. 更不用说有50个一些WSDL文件,其范围从200到1200行XML。 (Remind me again why we thought SOAP was the great salvation to us all back in the late 90s?) (再次提醒我为什么我们认为SOAP在90年代后期对我们所有人来说都是伟大的救赎?)

Try specifying all the WSDLs in one command: 尝试在一个命令中指定所有WSDL:

svcutil http://example.com/service1?wsdl http://example.com/service2?wsdl ...

This should automatically take care of duplicate types. 这应该自动处理重复的类型。 Another option is to take a look at the /reference command switch: 另一个选择是查看/reference命令开关:

/reference:<file path>        - Add the specified assembly to the set of
                                assemblies used for resolving type
                                references. If you are exporting or
                                validating a service that uses 3rd-party
                                extensions (Behaviors, Bindings and
                                BindingElements) registered in config use
                                this option to locate extension assemblies
                                that are not in the GAC.  (Short Form: /r)

This means that if you already have some types defined in some assembly you may include this assembly and svcutil will exclude types from it to avoid duplicates: 这意味着如果您已经在某些程序集中定义了某些类型,则可以包含此程序集,并且svcutil将从中排除类型以避免重复:

svcutil /reference:someassembly.dll http://example.com/service?wsdl

I have been using wsdl.exe to get round this because I work with some SOAP webservices which define the same data transfer objects at different endpoints. 我一直在使用wsdl.exe来解决这个问题,因为我使用了一些SOAP Web服务,它们在不同的端点定义相同的数据传输对象。 So I use wsdl.exe because it has the sharetypes switch. 所以我使用wsdl.exe,因为它有sharetypes开关。 I'm not a WPF developer so I don't really care that the output does not implement IWhatever for WPF, but the classes generated are all partial so you can do some work to implement interfaces you care about in a separate file. 我不是WPF开发人员所以我并不关心输出没有为WPF实现IWhatever,但生成的类都是部分的,所以你可以做一些工作来在一个单独的文件中实现你关心的接口。

I was having similar problems. 我遇到了类似的问题。 By defining different CLR namespaces for the different xml namespaces (using the /namespace argument of svcutil) i was able to get it working. 通过为不同的xml命名空间定义不同的CLR命名空间(使用svcutil的/ namespace参数),我能够使它工作。

/namespace:http://www.opengis.net/gml,OpenGIS.GML

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM