WCF 基地址 [英] WCF Base Addresses

查看:21
本文介绍了WCF 基地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

服务基地址和端点基地址有什么区别?

What is the difference between the service base address and the endpoint base address?

假设我有一个像这样的服务的基地址:"http://hostname:port/svc1" 并且服务的端点配置了 NetMsmqBinding,它需要一个传输方案"net.msmq"而不是http".这会导致 WCF 运行时出现异常,对吗?

Suppose i have a base address for the service like this: "http://hostname:port/svc1" and the endpoint of the service is configured with the NetMsmqBinding which requires a transport scheme "net.msmq" and not "http". This would result into an exception from the WCF runtime, right?

但是,这意味着服务的所有端点都必须符合服务基地址中指定的传输方案,对吗?

But then, this means that all endpoints of a service must conform to the transport scheme specified in the service base address, right?

有人可以帮忙解决这个歧义吗?

Can somebody please help solve this ambiguity?

推荐答案

每个方案你可以有一个基地址 - 所以你可以为 http 定义一个基地址,另一个用于 net.tcp 等等.

You can have one base address per scheme - so you can define one base address for http, another for net.tcp and so on.

基地址是地址的基址 - 每个端点都必须提供一个相对地址,它被添加到这个基地址:

The base address is the base of the address - each endpoint will have to provide a relative address which gets added to this base address:

  • http 的基地址:http://hostname:port/svc1
  • net.tcp 的基地址:net.tcp://hostname:port/tcp

  • Base address for http: http://hostname:port/svc1
  • Base address for net.tcp: net.tcp://hostname:port/tcp

端点 1:address="test1" --> 完整 URL http://hostname:port/svc1/test1

Endpoint 1: address="test1" --> complete URL http://hostname:port/svc1/test1

端点 2:address="test2" --> 完整 URL http://hostname:port/svc1/test2

Endpoint 2: address="test2" --> complete URL http://hostname:port/svc1/test2

net.tcp 的端点 1:address="tcp1" --> 完整 URL net.tcp://hostname:port/tcp/tcp1

Endpoint 1 for net.tcp: address="tcp1" --> complete URL net.tcp://hostname:port/tcp/tcp1

当然,即使有一个基地址,如果端点定义了它自己的完整地址,那么该地址将被使用:

And of course, even with a base address in place, if the endpoint defines it's own, complete address, then that address will be used:

  • 端点 3:address="http://hostname:port2/OtherService/EP1" --> 在这种情况下,由于指定了完整地址, 定义的基地址http适用,这个完全限定的地址实际的、完整的端点地址
  • Endpoint 3: address="http://hostname:port2/OtherService/EP1" --> in that case, since a complete address is specified , the defined base address for http does not apply and this fully qualified address IS the actual, complete endpoint address

这篇关于WCF 基地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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