WCF无法使用REST服务找到http的基地址

编程入门 行业动态 更新时间:2024-10-27 05:24:15
本文介绍了WCF无法使用REST服务找到http的基地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

尝试在IIS 6.0上运行我的REST WCF服务时,我看到WCF发出以下错误:

I'm seeing the following error coming from WCF when trying to hit my REST WCF service on IIS 6.0:

找不到与绑定WebHttpBinding的端点的方案http匹配的基地址.注册的基址方案为[].

Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [].

我的web.config看起来像:

My web.config looks like:

<system.serviceModel> <serviceHostingEnvironment> <baseAddressPrefixFilters> <!--LOCAL--> <add prefix="localhost/CustomTrackingService/CustomTrackingService.svc"/> <!--TEST--> <!--<add prefix="mytestserver/CustomTrackingService/CustomTrackingService.svc"/>--> </baseAddressPrefixFilters> </serviceHostingEnvironment> <services> <service name="MyService.CustomTrackingService"> <endpoint address="MyAction" binding="webHttpBinding" contract="MyContract.ICustomTrackingService" behaviorConfiguration="RestBehavior" /> </service> </services> <behaviors> <endpointBehaviors> <behavior name="RestBehavior"> <webHttp /> </behavior> </endpointBehaviors> </behaviors>

这在我的测试服务器上运行良好,并且在我让Casini抓取它的情况下在本地运行良好(将基本地址前缀localhost/CustomTrackingService更改为localhost:1234/).我不记得是什么原因导致了这种情况的发生,而且我的Google-fu无法产生有用的结果.有什么想法吗?

This works fine on my test server and works fine locally if I let Casini grab it (change base address prefix localhost/CustomTrackingService to localhost:1234/). I cannot remember what causes this to occur and my Google-fu is not producing useful results. Any ideas?

推荐答案

所以问题似乎是我在本地尝试使用未定义基地址的相对地址.这在我的测试服务器上有效,因为测试服务器错误地定义了多个主机头,这似乎转换为WCF中定义的多个基址,这是禁止的.我最初在测试服务器上使用了,因为我收到有关http的多个基址的错误,并且没有意识到真正的问题,所以我过滤掉了要使用的基址.由于我未定义主机头,因此无法在本地工作,因此过滤器未提供任何内容,并且由于未指定基地址,因此相对寻址尝试失败.

So looks like the problem is that locally i was trying to use a relative address with no base address defined. This worked on my test server because the test server incorrectly had more than one host header defined, which seems to translate into more than one base address defined in WCF, which is a no-no. i originally used the on the test server because i was getting an error about more than one base address for http, and without realizing the real problem, I filtered out the one I wanted using . Thsi won't work locally because I have no host headers defined, so the filter provided nothing and the relative addressing attempt failed because no base address was specified.

我将做更多的实验,以了解最适合我的情况的设置,但是检查IIS中的主机标头肯定会有所帮助.另外,此链接对理解实际情况有很大帮助.

I'm going to do some more experimenting to see what the best set-up for my situation is, but checking the host headers in IIS definitely helped. Also, this link was a huge help in understanding what was really going on.

更多推荐

WCF无法使用REST服务找到http的基地址

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

发布评论

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

>www.elefans.com

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