16

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). Each individual WSDL however has numerous shared type declarations. 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.

When I attempt to generate my client code, I bomb on these overlapping types that the 3rd party includes in all their WSDL files.

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. 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. Not to mention that there are 50 some WSDL files that range from 200-1200 lines of XML. (Remind me again why we thought SOAP was the great salvation to us all back in the late 90s?)

4

3 回答 3

2

Try specifying all the WSDLs in one command:

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:<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 /reference:someassembly.dll http://example.com/service?wsdl
于 2010-03-02T08:02:45.917 回答
0

我遇到了类似的问题。通过为不同的 xml 命名空间定义不同的 CLR 命名空间(使用 svcutil 的 /namespace 参数),我能够让它工作。

/namespace:http://www.opengis.net/gml,OpenGIS.GML
于 2010-09-19T10:29:26.710 回答
0

我一直在使用 wsdl.exe 来解决这个问题,因为我使用了一些 SOAP Web 服务,它们在不同的端点定义了相同的数据传输对象。所以我使用 wsdl.exe 因为它有 sharetypes 开关。我不是 WPF 开发人员,所以我并不关心输出没有为 WPF 实现 IWhatever,但生成的类都是部分的,因此您可以做一些工作来在单独的文件中实现您关心的接口。

于 2012-05-01T10:17:13.670 回答