Rya*_*ham 27 iis wcf config endpoint
所以我对服务端点和主机基地址的含义感到困惑.在到目前为止我已经走过的所有示例中,他们讨论了使用所需绑定设置端点,并且您通常可以导航到这些端点
当我使用以下配置来设置和托管我的服务时,它似乎只暴露了主机的基地址.
<configuration>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service name="HostService.EvalService">
<endpoint address="http://localhost:8080/basic"
binding="basicHttpBinding" contract="HostService.IEvalService" />
<endpoint address="http://localhost:8080/ws"
binding="wsHttpBinding" contract="HostService.IEvalService" />
<endpoint address="mex" binding="mexHttpBinding"
name="mex" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8080/EvalsService" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
Run Code Online (Sandbox Code Playgroud)
谁可以给我解释一下这个?
Kir*_*the 36
在IIS上承载WCF服务时,基址只能是.svc文件的URL.如果指定任何其他基址,则会被忽略.您仍然可以指定端点的相对URI,例如address="basic"或address = "ws".然后<URL to the .svc file>/basic,<URL to the .svc file>/ws在这种情况下,端点上的地址变为.
Has*_*san 19
当您将端点地址留空时,这意味着端点将仅使用相应的基址作为其端点地址.或者,您可以将基址配置为服务的绝对路径,或者作为更好的方法,为端点编写相对地址.
在IIS上托管服务时,服务基址由IIS虚拟目录和.svc文件确定.
假设您有一个名为calc.svc的文件,并将其放在对应于"http:// localhost:8080/calcservice"的虚拟目录中.该服务的基地址为'http:// localhost:8080/calcservice/calc.svc'.
IIS强制您的端点使用根据您的服务部署路径确定的此基址.如果指定不同的基址,则指定相应的虚拟目录,您将获得异常.
考虑下面的配置;
<configuration>
<system.serviceModel>
<services>
<service name="CalculatorService">
<!-- base address determined by IIS virtual directory -->
<endpoint binding="basicHttpBinding" contract="ISimpleMath"/>
<endpoint address="secure" binding="wsHttpBinding" contract="ISimpleMath"/>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
...
Run Code Online (Sandbox Code Playgroud)
...第一个端点的地址与基地址('http:// localhost:8080/calcservice/calc.svc')相同,因为我将端点地址留空了.第二个端点的地址成为附加"安全"的基址的组合,如下所示:'http:// localhost:8080/calcservice/calc.svc/secure'.并且"mex"端点的地址是"http:// localhost:8080/calcservice/calc.svc/mex".这对某些人来说似乎有点奇怪,因为地址的相对部分被添加到文件名的右侧,但你必须记住calc.svc是基地址的一部分,所以它必须以这种方式工作.
虽然您无法通过浏览器导航到"../mex"或"../secure"URL,但它们实际上是活动的,客户端可以使用这些地址.
客户行为
客户端不了解服务的基地址,也不需要在线路上支持类似的东西.因此,您将无法在客户端对象模型或配置部分中找到与基址相关的任何内容.客户端只需选择一个特定的端点,该端点始终配置有绝对地址,该绝对地址决定了它在传输过程中将使用的地址.
以上信息主要摘自Aaron Skonnard 关于msdn 的优秀文章.我强烈建议你阅读它以获得WCF寻址背后的基础知识.
小智 6
当您使用基地址时,您不需要为端点提供绝对URI,例如,您可以address="basic"在端点配置部分中使用,这意味着该端点的地址是http://localhost:8080/EvalsService/basic.
| 归档时间: |
|
| 查看次数: |
69556 次 |
| 最近记录: |