问题描述
使用SvcUtil工具我生成一个SOAP WebService的代理。此WebService有许多复杂的类型,每年可以改变。是否有一个工具,我可以用它来生成所有类包装。在包装类,我会叫代理类使用成分。
Using SvcUtil I generated proxy for a SOAP WebService. This webservice has many complex types and can change every year. Is there a tool I can use to generate wrapper for all classes. Using composition in wrapper class I will call proxy class.
推荐答案
svcutil.exe的根据XSD生成POCO类型的客户端两侧的WSDL份。不应该有T4Template参与这也太复杂,矫枉过正和不恰当的。 svcutil.exe的可能已经创建你需要的所有代理类。
Svcutil.exe generate POCO types at the client sides according to the XSD parts of WSDL. There shouldn't be T4Template involved which is too complex and overkill and inappropriate. Svcutil.exe could have created all the proxy classes you need.
如果复杂类型可能会改变每一年,你可以考虑的版本。
If the complex types may be changing every years, you may consider versioning.
在一个界面发布后,您不应该改变它。这适用于经营合同和数据契约。
Once an interface is published, you should not changed it. This applies to both operation contracts and data contracts.
您可以参考本文的以及谷歌WCF版本。
You may refer to this article WCF for the Real World, and google WCF versioning.
所以基本上你明确声明在合同XML目标命名空间,和CLR命名空间与XML命名空间映射。当您需要更改复杂类型,你必须提供WCF服务的另一个版本。在过渡期内的所有客户端可以升级到最新版本之前,你把两个版本运行。
So basically you explicitly declare XML target namespace in the contracts, and map CLR namespaces with XML namespaces. When you need to change the complex types, you have to provide another version of WCF service. During the transition period before all the clients could upgrade to the latest version, you keep both versions running.
这篇关于.NET工具生成代理类包装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!