为客户端动态配置Web服务端点 [英] Dynamically Configure Web Service Endpoint for Client(s)

查看:84
本文介绍了为客户端动态配置Web服务端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我已经开发了一个利用Web服务的客户端应用程序.众所周知,客户端应用程序使用其配置文件来获取Web服务的端点地址.例如:

Hi all,

I have developed a client application that makes use of a web service. As most of you know, the client application makes use of it''s configuration file to get the endpoint address of the web service. For example:

<client>
  <endpoint address="https://server.local/service.asmx"

      binding="basicHttpBinding" bindingConfiguration="Service"

      contract="ServiceReference.Service" name="Service" />
</client>



这让我想到了一个问题:如何动态配置每个客户端的端点地址,而无需在配置文件中手动设置地址(手动指的是使用答案2中所述的方法).我当时在考虑查询DNS服务器,但是我真的不确定最好的方法是什么?有指针吗?

提前非常感谢.
亲切的问候,



Which brings me to my question, how can I dynamically configure the endpoint address of each client without setting the address manually (manually refers to using a method as described in Answer 2) within the configuration file. I was thinking in the line of querying the DNS server, but I am really not sure what the best approach would be?? Any pointers?

Many thanks in advance.
Kind regards,

推荐答案

如果您的要求是通过代码设置端点地址,而不是在配置文件中进行设置,则可以这样做,

If your requirement is to set the endpoint address through code instead of setting it in the config file, you can do it like this,

ServiceReference.Service service = new ServiceReference.Service();
service.Endpoint.Address = new EndpointAddress("http://localhost/MyServiceTest/Service.asmx");


这篇关于为客户端动态配置Web服务端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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