简体   繁体   English

如何使用同一WCF Web服务的不同版本?

[英]How can I consume different versions of the same WCF web service?

I have a few versions of a WCF web service(being developed by a 3rd party) that I need to support using a single application, depending on the parameters passed into it. 我有几个版本的WCF Web服务(由第三者开发),我需要使用单个应用程序来支持它,具体取决于传递给它的参数。

I have read that I must add a service reference to my project in order to use the WCF service. 我已经读到必须为我的项目添加服务引用才能使用WCF服务。

Does this mean that I must add a service reference for each different version of the web service I am supporting (and by extension, each new version of the web service as it comes out as well)? 这是否意味着我必须为我所支持的Web服务的每个不同版本添加一个服务引用(并且通过扩展,每个新版本的Web服务也要添加)?

Some have suggested that you could simply change the endpoint for the service. 有人建议您可以简单地更改服务的端点。 Would this allow me to reference any newly added functions, or only the ones included in the service reference I initially imported? 这将允许我引用任何新添加的功能,还是仅引用最初导入的服务引用中包含的功能?

Or is there a way to dynamically create and use a service reference at runtime (which means I could simply create a service reference based on a uri)? 还是有一种方法可以在运行时动态创建和使用服务引用(这意味着我可以简单地基于uri创建服务引用)? If so, how would Visual Studio know which web service functions were valid at compile time? 如果是这样,Visual Studio将如何在编译时知道哪些Web服务功能有效?

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

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