WCF 服务端点与主机基地址

编程入门 行业动态 更新时间:2024-10-27 03:30:25
本文介绍了WCF 服务端点与主机基地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

所以我对服务端点和主机基址的用途有点困惑.在我到目前为止所经历的所有示例中,他们都谈到使用所需的绑定设置端点,您通常可以导航到这些端点

然而,当我使用以下配置来设置和托管我的服务时,它似乎只公开了主机基地址.

<system.web><编译调试=真"/></system.web><!-- 部署服务库项目时,必须将config文件的内容添加到宿主机的app.config 文件.System.Configuration 不支持库的配置文件.--><system.serviceModel><服务><服务名称="HostService.EvalService"><端点地址="localhost:8080/basic"binding="basicHttpBinding" contract="HostService.IEvalService"/><端点地址="localhost:8080/ws"binding="wsHttpBinding" contract="HostService.IEvalService"/><端点地址=mex"绑定=mexHttpBinding"name="mex" contract="IMetadataExchange"/><基地址><add baseAddress="localhost:8080/EvalsService"/></baseAddresses></host></服务></服务><行为><服务行为><行为名称=""><serviceMetadata httpGetEnabled="true"/><serviceDebug includeExceptionDetailInFaults="false"/></行为></serviceBehaviors></行为></system.serviceModel></配置>

有人可以向我解释一下吗?

解决方案

在 IIS 上承载 WCF 服务时,基地址只能是 .svc 文件的 URL.如果您指定任何其他基地址,它将被忽略.您仍然可以为端点指定相对 URI,例如 address="basic" 或 address = "ws".然后端点上的地址在这种情况下变为 /basic 和 /ws.>

so i'm a litle confused over what the service endpoints and host base address is for. In all the examples i have walked through so far they talk about setting up the endpoints with the required bindings and you can normally navigate to those endpoints

Hoever when i use the following config to set up and host my service it only seems to expose the Hosts base address.

<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="localhost:8080/basic" binding="basicHttpBinding" contract="HostService.IEvalService" /> <endpoint address="localhost:8080/ws" binding="wsHttpBinding" contract="HostService.IEvalService" /> <endpoint address="mex" binding="mexHttpBinding" name="mex" contract="IMetadataExchange" /> <host> <baseAddresses> <add baseAddress="localhost:8080/EvalsService" /> </baseAddresses> </host> </service> </services> <behaviors> <serviceBehaviors> <behavior name=""> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="false" /> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> </configuration>

Can someone explain this to me?

解决方案

When you host the WCF service on IIS, the base address can only be the URL to the .svc file. If you specify any other base address, it's ignored. You can still specify the relative URI for your endpoints, such as address="basic" or address = "ws". Then the address on the endpoint becomes <URL to the .svc file>/basic and <URL to the .svc file>/ws in this case.

更多推荐

WCF 服务端点与主机基地址

本文发布于:2023-11-07 09:05:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1566053.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:主机   基地   WCF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!