简体   繁体   English

从WSDL生成代理

[英]Generate Proxy from WSDL

I have a single self-contained (third party) WSDL file with say 10 operations. 我有一个包含10个操作的独立的(第三方)WSDL文件。 (server is not .net) All operations have their own XML namespaces defined for operations, messages and all the underlying types. (服务器不是.net)所有操作都为操作,消息和所有基础类型定义了自己的XML名称空间。

Some of the underlying types in different operations have same names and sometimes same content or same structure (not always) as well but they are actually different as they are defined in different xml/xsd namespaces (so they are unique). 不同操作中的某些基础类型具有相同的名称,有时也具有相同的内容或相同的结构(并非总是如此),但实际上它们是不同的,因为它们是在不同的xml / xsd命名空间中定义的(因此它们是唯一的)。

When I import this WSDL into my c# client project, I can give it one unique namespace in the VS porject and it generates the proxy/stub. 当将此WSDL导入到我的c#客户端项目中时,可以在VS项目中为其指定一个唯一的名称空间,并生成代理/存根。 The problem is wherever the different operations have same (xml type) names for the underlying types then it generates the c# class names like: MyType1, MyType2... 问题在于,不同的操作在基础类型中具有相同的(xml类型)名称,然后它会生成c#类名称,例如:MyType1,MyType2 ...

Additionally the third party server, can update the service and so the WSDL is updated and the underlying types are generated again into .net classes like MyType1, MyType2... but this time, maybe previously generated MyType6 is generated as MyType7 and this breaks the client/consumer code. 此外,第三方服务器可以更新服务,因此将更新WSDL,并再次将基础类型生成为.net类,例如MyType1,MyType2 ...,但这一次,也许以前生成的MyType6被生成为MyType7,这打破了客户/消费者代码。

What solution exists to address this problem? 有什么解决方案可以解决此问题?

We are thinking to customize the wscfblue code but it seem to be a cumbersome work and would require maintenance.. 我们正在考虑自定义wscfblue代码,但这似乎是一项繁琐的工作,并且需要维护。

Environment:
-VS2013 Ultimate (Client)
-.net 4.5 (Client)
-Unknown technology (Server) -> generates WSDL and provides the endpoint.

You can generate the proxy using svcutil.exe and provide mappings from xml namespaces to CLR namespaces with /n. 您可以使用svcutil.exe生成代理,并使用/ n提供从xml名称空间到CLR名称空间的映射。 It also supports multiple mappings, which it sounds like you need. 它还支持多种映射,听起来像您需要的。

Example: use svcutil to map multiple namespaces for generating wcf service proxies 示例: 使用svcutil映射多个名称空间以生成WCF服务代理

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

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