同一 WCF 服务的多个客户端端点

发布于 2024-09-28 22:42:27 字数 397 浏览 0 评论 0原文

我有一个在 LAN IIS 上运行的 WCF 服务,也可以通过 Internet 访问该服务。

使用服务的客户端是在 LAN 上运行并通过 Internet 远程运行的应用程序。 DNS 服务器上没有转发任何内容,将 http://www.corporate.com/Service 重定向到http://serverName/Service 所以我想客户端上需要 2 个端点。

如何在客户端中设置多个端点(是否像复制 app.config 中生成的现有端点但更改地址一样简单?)以及如何配置客户端以使用特定端点?

I've got a WCF service running on a LAN IIS which is accessible from the internet as well.

The client that consumes the service is an application that runs on the LAN and remotely through the internet. There is no forwarding of anything on the DNS server redirecting http://www.corporate.com/Service to http://serverName/Service so I'm figuring I'll need 2 endpoints on the client.

How do you setup multiple endpoints in the client (is it as simple as copying the existing enpoint generated in the app.config but changing the address?) and how do you configure the client to use a particular endpoint?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一紙繁鸢 2024-10-05 22:42:27

您可以将端点地址存储在 app.config 或资源字符串中。然后使用任何条件将所需的端点地址传递给服务构造函数。

var endpoint = ApplicationSettings.IsRemote ? Resources.RemoteEndPoint: Resources.LocalEndPoint;
var service = new MyWCFService(new BasicHttpBinding(), new Endpoint(endpoint));

You may store endpoint addresses either at app.config, or at resource strings. Then using any condition you pass needed endpoint address to service constructor.

var endpoint = ApplicationSettings.IsRemote ? Resources.RemoteEndPoint: Resources.LocalEndPoint;
var service = new MyWCFService(new BasicHttpBinding(), new Endpoint(endpoint));
不爱素颜 2024-10-05 22:42:27

应用程序的每个副本的 app.config(或 web.config)应具有根据其需要设置的服务端点。对于 LAN 安装,请使用 LAN 可见端点;对于所有其他人,请使用互联网。

它可能会帮你省去路由器的麻烦,但为什么不直接在任何地方使用互联网端点呢?如果您的 LAN 计算机有通往网络的网关,它们可以看到外部可见的地址。

The app.config (or web.config) for each copy of the application should have the endpoint for the service set based on the one it needs. For LAN installations, use the LAN-visible endpoint; for all others, use the Internet one.

It may save you a trip to the router, but why not just use the internet endpoint everywhere? If your LAN computers have a gateway to the Net, they can see the externally-visible address.

瑶笙 2024-10-05 22:42:27

它就像更改地址并使用应用程序配置中生成的端点一样简单。您可能需要更改安全模式,具体取决于任一服务器支持的内容,或者它们是否都运行 HTTPS。我们有一个应用程序,我们根据 Silverlight 应用程序中当前 URL 的相对路径构建目标端点。我们还根据 HTTPS 的存在动态更改安全模式,效果非常好。

It is as simple as changing the address and using the endpoint generated in the app config. You may have to change security modes depending on what is supported on either server, or whether they are both running HTTPS or not. We have an application where we build the target endpoint based on relative path to the current URL in a Silverlight application. We also dynamically change the security mode based on HTTPS being present and it works great.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文