bak*_*san 17 c# soap wsdl svcutil.exe
构建一个依赖于第三方提供商的应用程序,该提供商拥有非常冗长的SOAP服务(我们正在讨论50多个WSDL文件).但是,每个单独的WSDL都有许多共享类型声明.使用wsdl.exe生成客户端代码时,曾经有一个/ sharedtypes标志,如果多次找到类型,它将合并重复的条目.
当我尝试生成我的客户端代码时,我会轰炸第三方在其所有WSDL文件中包含的这些重叠类型.
svcutil /t:code /importxmltypes [mypath]/*.wsdl
Run Code Online (Sandbox Code Playgroud)
导致错误消息导致类型冲突.例如,以下错误消息的几个示例:
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.
Run Code Online (Sandbox Code Playgroud)
我无法控制WSDL的输出.我不想手动编辑WSDL,因为担心在运行时以某种方式破坏的错误很难追溯到我们编辑WSDL文件.更不用说有50个一些WSDL文件,其范围从200到1200行XML.(再次提醒我为什么我们认为SOAP在90年代后期对我们所有人来说都是伟大的救赎?)
尝试在一个命令中指定所有 WSDL:
svcutil http://example.com/service1?wsdl http://example.com/service2?wsdl ...
Run Code Online (Sandbox Code Playgroud)
这应该会自动处理重复的类型。另一个选择是查看/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)
Run Code Online (Sandbox Code Playgroud)
这意味着,如果您已经在某个程序集中定义了某些类型,您可以包含此程序集并svcutil从中排除类型以避免重复:
svcutil /reference:someassembly.dll http://example.com/service?wsdl
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4311 次 |
| 最近记录: |