你如何修改在运行时的服务引用的位置? [英] How do you modify the location of a service reference at runtime?

查看:325
本文介绍了你如何修改在运行时的服务引用的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个客户端的VB .NET 3.5 WPF应用程序基本上是一个测试工具 - 它调用一个Web服务(一个典型的.NET 2.0 Web服务,而不是一个WCF的应用程序),这是在同一个解决方案。检查一些服务方法正确运行。

I have a client VB .NET 3.5 WPF app which is basically a test harness - it calls a webservice (a classic .NET 2.0 webservice, NOT a WCF app) that's in the same solution. to check some of the service methods runs correctly.

我添加的服务,在VS中的客户机项目作为服务引用,并为这两个项目是启动项目的解决方案。这工作正常,当我调试,并在本地运行整个事情。但问题是,我需要的用户能够在一个URL在运行时类型,并有测试工具检查出的服务在指定的网址,而不是一个在那VS正在运行的位置。这是为了让测试工具可以检查出的Web服务已经部署副本。问题是,似乎没有任何办法,在服务引用,使URL动态和可设置从VB code。是否有可能这样做吗?

I've added the service to the the client project in VS as a Service Reference, and set the solution for both projects to be startup projects. That works fine when I'm debugging and running the whole thing locally. But the problem is, I need the user to be able to type in a URL at runtime, and have the test harness check out the service at the specified URL, not the one at the location that VS is running. This is so the test harness can check out already deployed copies of the web service. The problem is there doesn't seem to be any way in the service reference to make the URL dynamic and settable from the VB code. Is it possible to do that?

推荐答案

我觉得你可以动点客户端服务。该服务引用是为您服务的代理。

I think you can dynamic point client to service. The service reference is a proxy of your service.

我相信,你可以使用的服务引用(服务代理),它接受一个URL作为参数,其他构造。

I belive that you can use the other constructor of service reference(service proxy) that take a Url as parameter.

例如。 YourServiceProxy(目标URL)

e.g. YourServiceProxy("Target url")

如果你的用户改变/编辑服务的URL,我觉得你可以initail其他服务代理实例采取URL哪些用户指定。

If you user change/edit the service url, i think you can initail other service proxy instance that take url which user specify.

这篇关于你如何修改在运行时的服务引用的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆