WCF 启用multipleSiteBindingsEnabled 情况下报终结点地址错误
报错信息如下:
Server Error in '/MyWcfService' Application.
When 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' is set to true in configuration, the endpoints are required to specify a relative address. If you are specifying a relative listen URI on the endpoint, then the address can be absolute. To fix this problem, specify a relative uri for endpoint 'http://127.0.0.1/MyWcfService/Calculatorservice.svc'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: When 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' is set to true in configuration, the endpoints are required to specify a relative address. If you are specifying a relative listen URI on the endpoint, then the address can be absolute. To fix this problem, specify a relative uri for endpoint 'http://127.0.0.1/MyWcfService/Calculatorservice.svc'.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: When 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' is set to true in configuration, the endpoints are required to specify a relative address. If you are specifying a relative listen URI on the endpoint, then the address can be absolute. To fix this problem, specify a relative uri for endpoint 'http://127.0.0.1/MyWcfService/Calculatorservice.svc'.]
System.ServiceModel.Activation.ApplyHostConfigurationBehavior.ThrowIfAbsolute(Uri uri) +143946
System.ServiceModel.Activation.ApplyHostConfigurationBehavior.FailActivationIfEndpointsHaveAbsoluteAddress(ServiceHostBase service) +153
System.ServiceModel.Description.DispatcherBuilder.ValidateDescription(ServiceDescription description, ServiceHostBase serviceHost) +391
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +334
System.ServiceModel.ServiceHostBase.InitializeRuntime() +82
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +64
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +789
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +255
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +1172
[ServiceActivationException: The service '/MyWcfService/Calculatorservice.svc' cannot be activated due to an exception during compilation. The exception message is: When 'system.serviceModel/serviceHostingEnvironment/multipleSiteBindingsEnabled' is set to true in configuration, the endpoints are required to specify a relative address. If you are specifying a relative listen URI on the endpoint, then the address can be absolute. To fix this problem, specify a relative uri for endpoint 'http://127.0.0.1/MyWcfService/Calculatorservice.svc'..]
System.Runtime.AsyncResult.End(IAsyncResult result) +900576
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +193150
System.Web.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar) +107
配置文件:
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="metadataBehavior" name="MyWcf.MyWcfService.CalculatorService">
<endpoint address="http://localhost:2821/Calculatorservice.svc" binding="wsHttpBinding" contract="MyWcf.MyWcfContracts.ICalculator"/> </service>
<service behaviorConfiguration="metadataBehavior" name="MyWcf.MyWcfService.DealWithFault">
<endpoint address="http://localhost:2821/DealWithFault.svc" binding="wsHttpBinding" contract="MyWcf.MyWcfContracts.IDealWithFault"/> </service>
</services>
根据报错提示,在启用multipleSiteBindingsEnabled="true"的情况下,需要为终结点指定相对uri。
给定终结点地址一个base address:
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior name="metadataBehavior">
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="metadataBehavior" name="MyWcf.MyWcfService.CalculatorService">
<endpoint binding="wsHttpBinding" contract="MyWcf.MyWcfContracts.ICalculator"/>
<host>
<baseAddresses>
<!--将service发布到IIS上的配置,需配置IIS虚拟目录,例如:MyWcfService-->
<!--<add baseAddress="http://localhost/MyWcfService/Calculatorservice.svc"/>-->
<!--将service发布到VS web deployment上的配置,项目-Property设置了虚拟目录“/”,如果发布在http://localhost/MyWcfService下,需要设置虚拟目录为“/MyWcfService”-->
<add baseAddress="http://localhost:2821/Calculatorservice.svc"/>
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="metadataBehavior" name="MyWcf.MyWcfService.DealWithFault">
<endpoint binding="wsHttpBinding" contract="MyWcf.MyWcfContracts.IDealWithFault"/>
<host>
<baseAddresses>
<!--将service发布到VS web deployment上的配置-->
<add baseAddress="http://localhost:2821/DealWithFault.svc"/>
</baseAddresses>
</host>
</service> </services>
具体WCF的地址拼接方法相关原因可参照:http://social.msdn.microsoft.com/Forums/en-US/ef113ca3-4636-4031-b9de-f651dce07b76/wcfiis
如下:
“address在终结点里,简单理解就是地址,终结点地址。
你可以配置address为相对,也可以是全部完整格式的地址。当你有基地址时,这里可以使用相对地址,终结点的地址就是 基地址+相对地址。
当你使用完整的地址格式,那终结点地址就不会使用 基地址+相对地址。
IIS部署的时候,默认会有一个基地址Baseaddress,这个是根据你WCF服务程序的配置生成的。
如果你打算提供完成的地址格式,但是这个完成的地址格式 和Baseaddress 不匹配,比如端口不一样,就会出错。
address换成“”,目的就是使用默认的Baseaddress+“”。避免了你自己设置的和Baseaddress 不匹配的问题。”
WCF 启用multipleSiteBindingsEnabled 情况下报终结点地址错误的更多相关文章
- 关于WCF服务在高并发情况下报目标积极拒绝的异常处理
最近弄了个wcf的监控服务,偶尔监控到目标服务会报一个目标积极拒绝的错误.一开始以为服务停止了,上服务器检查目标服务好好的活着.于是开始查原因. 一般来说目标积极拒绝(TCP 10061)的异常主要是 ...
- WCF服务在高并发情况下报目标积极拒绝的异常处理 z
http://www.cnblogs.com/kklldog/p/5037006.html wcf的监控服务,偶尔监控到目标服务会报一个目标积极拒绝的错误.一开始以为服务停止了,上服务器检查目标服务好 ...
- 奇怪的bug,不懂Atom在添加markdown-themeable-pdf,在配置好phantomjs的情况下报错
本来打算用一下atom但是导出pdf报错,可是在预览的情况下就没有问题,顺便吐槽一下谷歌浏览器自己的markdown在线预览插件无法适配,用搜狗搭载谷歌的插件才能导出pdf,一下感觉逼格少了很多,等忙 ...
- 关于JDBC技术中,调用MySQL中不建议在没有服务器身份验证的情况下建立SSL连接错误解决
今天学习到了JBDC前沿:对JDBC编写步骤的封装,出现了一大串红色报错(当然,也不能叫报错,毕竟不是所有的红色都是错误eeror,) 错误如下: Establishing SSL connectio ...
- Thinkphp+Nginx(PHPstudy)下报的404错误,403错误解决
最近一个TP5的项目说放到Nginx下测试看看,下载个 PHPstudy,放到WWW下,配置好域名,直接给个报个404: 解决方法: 1.先在phpstudy下配置好域名目录指向项目下的public下 ...
- C# WCF学习笔记(二)终结点地址与WCF寻址(Endpoint Address and WCF Addressing) WCF中的传输协议
URI的全称是 Uniform Rosource Identifire(统一资源标识),它唯一标识一个确定的网绐资源,同时也表示资源所处的位置及访问的方式(资源访问所用的网络协议). 对于Endpoi ...
- wcf服务各种情况下应用
1.控制台调用 第一步,添加wcf服务 2.写接口,记得要加好契约特性. 3.声明一个类继承wcf服务. 4.ipconfig配置 5.控制台运行 6.运行app.config里面,加上调用的接口方法 ...
- laravel项目return back()->withErrors($validator)或return back()->with('errors','原密码错误!')在前台原密码错误的情况下不能正确显示错误信息,变成报错!
被折磨的答案是 php artisan --version看一下版本,如果是5.2.26以上的,在路由处删除web中间件分组,还有问题再反馈
- Service Fabric 群集在Service Replica过多的情况下报错问题
首先 Service Fabric 群集是正常的,部署一些服务过后也能正常运行,但一旦部署的服务过多后,且每个服务不止一个Partition,就有可能让群集状态为Error,但其实服务还是在正常运行的 ...
随机推荐
- VC++深入详解读书笔记-第七章对话框
1.在MFC中,所有的控件类都是由CWnd类派生来的,因此,控件实际上也是窗口. 2. 3.对话框的种类 模态对话框 模态对话框是指当其显示时,程序会暂时执行,直到关闭这个模态对话框后,才能继续执行程 ...
- 为什么所有浏览器的userAgent都带Mozilla
参看下面链接:<为什么所有的浏览器的userAgent都带Mozilla>
- spring注解注入:<context:component-scan>使用说明
spring从2.5版本开始支持注解注入,注解注入可以省去很多的xml配置工作.由于注解是写入java代码中的,所以注解注入会失去一定的灵活性,我们要根据需要来选择是否启用注解注入. 在XML中配置了 ...
- j2ee基础
1.tomcat端口被占用解决方式 使用netstat -anb查看哪个进程占用,禁止掉 修改tomacat使用的端口,在配置文件conf/server.xml 2.web app目录 3.如何建立虚 ...
- jquery学习之笔记一
jquery是继prototype后一个很好用的javascript库.jquery是一个轻量级的库,拥有强大的选择器,出色的DOM操作,可靠的事件处理,完善的兼容性和链式操作等功能. window. ...
- 03-树2. Tree Traversals Again (25)
03-树2. Tree Traversals Again (25) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue ...
- SQL Server 的内存分类
第一类. 根据申请方式分: commit 型 它是指先reserve申请一大块,再通过commit提交后得到的空间.这种方式申请到的空间可以启用 awe ! stolen型 与commit 相对应!它 ...
- codility上的练习(3)
今天发现又出了lesson 3... 不过题目都很简单…… (1) Min-avg-slice 给定一个长度为n的整数数组,找到一个连续的子数组,数组元素的平均值最小. 数据范围N [1..10^5] ...
- win7系统怎样备份
利用系统自带的备份还原 1 这种方法的缺点是如果以后系统出现问题,无法进入系统的话,就无法恢复系统了.首先我们点击开始菜单,打开控制面板! 2 在控制面板中点击系统和安全! 3 我们选择备份和还原中的 ...
- linux命令之mv
linux下的mv即move的意思 该命令的一般形式: mv [选项] 参数1 参数2 选项: -b 如果已存在相同文件名,则覆盖前进行备份 -f ...