报错信息如下:

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 情况下报终结点地址错误的更多相关文章

  1. 关于WCF服务在高并发情况下报目标积极拒绝的异常处理

    最近弄了个wcf的监控服务,偶尔监控到目标服务会报一个目标积极拒绝的错误.一开始以为服务停止了,上服务器检查目标服务好好的活着.于是开始查原因. 一般来说目标积极拒绝(TCP 10061)的异常主要是 ...

  2. WCF服务在高并发情况下报目标积极拒绝的异常处理 z

    http://www.cnblogs.com/kklldog/p/5037006.html wcf的监控服务,偶尔监控到目标服务会报一个目标积极拒绝的错误.一开始以为服务停止了,上服务器检查目标服务好 ...

  3. 奇怪的bug,不懂Atom在添加markdown-themeable-pdf,在配置好phantomjs的情况下报错

    本来打算用一下atom但是导出pdf报错,可是在预览的情况下就没有问题,顺便吐槽一下谷歌浏览器自己的markdown在线预览插件无法适配,用搜狗搭载谷歌的插件才能导出pdf,一下感觉逼格少了很多,等忙 ...

  4. 关于JDBC技术中,调用MySQL中不建议在没有服务器身份验证的情况下建立SSL连接错误解决

    今天学习到了JBDC前沿:对JDBC编写步骤的封装,出现了一大串红色报错(当然,也不能叫报错,毕竟不是所有的红色都是错误eeror,) 错误如下: Establishing SSL connectio ...

  5. Thinkphp+Nginx(PHPstudy)下报的404错误,403错误解决

    最近一个TP5的项目说放到Nginx下测试看看,下载个 PHPstudy,放到WWW下,配置好域名,直接给个报个404: 解决方法: 1.先在phpstudy下配置好域名目录指向项目下的public下 ...

  6. C# WCF学习笔记(二)终结点地址与WCF寻址(Endpoint Address and WCF Addressing) WCF中的传输协议

    URI的全称是 Uniform Rosource Identifire(统一资源标识),它唯一标识一个确定的网绐资源,同时也表示资源所处的位置及访问的方式(资源访问所用的网络协议). 对于Endpoi ...

  7. wcf服务各种情况下应用

    1.控制台调用 第一步,添加wcf服务 2.写接口,记得要加好契约特性. 3.声明一个类继承wcf服务. 4.ipconfig配置 5.控制台运行 6.运行app.config里面,加上调用的接口方法 ...

  8. laravel项目return back()->withErrors($validator)或return back()->with('errors','原密码错误!')在前台原密码错误的情况下不能正确显示错误信息,变成报错!

    被折磨的答案是 php artisan --version看一下版本,如果是5.2.26以上的,在路由处删除web中间件分组,还有问题再反馈

  9. Service Fabric 群集在Service Replica过多的情况下报错问题

    首先 Service Fabric 群集是正常的,部署一些服务过后也能正常运行,但一旦部署的服务过多后,且每个服务不止一个Partition,就有可能让群集状态为Error,但其实服务还是在正常运行的 ...

随机推荐

  1. linux网络编程:三次握手与四次挥手

    建立TCP需要三次握手才能建立,而断开连接则需要四次握手.整个过程如下图所示: 其中三次握手即建立连接 四次挥手则为关闭连接 TCP连接的11种状态 客户端独有的:(1)SYN_SENT (2)FIN ...

  2. 资源回收 left

    select DISTINCT human.tid,log_pv_change.systafftid from human left join human_user on human.tid=huma ...

  3. 匈牙利算法(素数伴侣(HW1112))

    #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<vector> #include<string&g ...

  4. MySQL load data infile

    语法: load data [low_priority] [local] infile ‘file_path' [replace] [ignore] into table table_name [(c ...

  5. Delphi与字符编码(实战篇)(MultiByteToWideChar会返回转换后的宽字符串长度)

    本文目标: 了解Delphi的字符串类型 字符编码的检测与转换 简体繁体转换 0. 导言 看完“.Net与字符编码(理论篇)”,我们明白了字符是自然语言中的最小单位,在存储和传输的过程中可以使用三种编 ...

  6. Binary Tree Level Order Traversal - leetcode - java

    Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, ...

  7. 打印 上一主题 下一主题 利用cURL实现单个文件分多段同时下载,支持断点续传(修订版)

      利用cURL实现单个文件分多段同时下载,支持断点续传(修订版) [复制链接] 摘自 http://bbs.chinaunix.net/thread-917952-1-1.html 在ubuntu下 ...

  8. 当浏览器不支持placeholder,所执行的函数

    $(function(){ //判断浏览器是否支持placeholder属性 supportPlaceholder='placeholder'in document.createElement('in ...

  9. 关于xxx.h file not found 的问题

    在引用第三方库的时候,经常会遇到xxx.h file not found的问题. 首先,我们要知道在引用第三方的时候,我们使用的第三方的库的类型. .a静态库 使用方式:#import "x ...

  10. GitHub以及Git学习 持续编辑学习中

    官网地址: http://www.worldhello.net/gotgithub/01-explore-github/030-explore-github.html 1 加入github, http ...