Spring.NET 的 WCF WebService 找不到基址方案 http
我搜索整个互联网来解决这个问题,虽然我发现了非常相似的问题,但没有一个是我自己的。事情是这样的:
我想使用 Spring.NET 1.3.1 配置 WCF Web 服务(.Net 4.0 和 VS 2010)。用于依赖注入。我现在使用的是 IIS 7(但稍后我可能需要为不同的 IIS 设置它)。
我没有将其配置为使用 HTTPS 运行(我将来可能会想要,但现在不是这种情况)。
我首先在没有 Spring.NET 的情况下配置了 WCF Web 服务,它运行得非常完美!
场景 1:
然后我添加了以下内容:
<object id="geoServiceWCF" type="ExampleProj.Web.WebServices.GeoServiceWCF" singleton="false" >
</object>
<object id="GeoServiceWCFServiceHost" type="Spring.ServiceModel.Activation.ServiceHostFactoryObject, Spring.Services">
<property name="TargetName" value="geoServiceWCF" />
</object>
...我遇到了以下异常: 找不到与绑定 WebHttpBinding 的端点的方案 http 相匹配的基地址。注册的基址方案是 []。(创建名为“GeoServiceWCFServiceHost”的对象时出错)
这是我的 WCF Web.Config 部分:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="AJAXFriendly">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="geoServiceWCF">
<endpoint address=""
behaviorConfiguration="AJAXFriendly"
binding="webHttpBinding"
contract="ExampleProj.Web.WebServices.IGeoServiceWCF" >
</endpoint>
</service>
</services>
</system.serviceModel>
场景 2:< /strong>
如果我将 address="http://localhost/ExampleProj/WebServices/GeoServiceWCF.svc" 定义为异常建议,我会收到另一个错误: ServiceMetadataBehavior 的 HttpGetEnabled 属性设置为 true,HttpGetUrl 属性是相对地址,但没有 http 基地址。提供 http 基地址或将 HttpGetUrl 设置为绝对地址。 (创建名为“GeoServiceWCFServiceHost”的对象时出错)
场景 3:
然后,如果我设置httpGetEnabled="true",我会收到访问被拒绝错误。
详细信息:尝试注册 URL 地址 http://+:80/ExampleProj/WebServices 时出现一些问题/GeoServiceWCF.svc/ (是的,带有“+”符号)
摘要
我按照 Spring.NET 文档中的简单步骤进行操作。我想我错过了一些东西,因为 我不敢相信我必须设置这么多奇怪的参数才能使它工作。
抱歉问了这么长的问题,我想提供尽可能多的信息。
提前致谢!!
I search the entire internet to solve this problem and although I found very similar problems, none of them were my own. Here's the deal:
I want to configure a WCF Web Service (.Net 4.0 and VS 2010) with Spring.NET 1.3.1. for Dependence Injection. I'm using IIS 7 now (but I probably need to set it up for a different IIS later).
I'm NOT configuring this to run with HTTPS (I'll probably want in the future, but that's not the case right now).
I first configured the WCF Web Service without Spring.NET and it worked perfect!
Scenario 1:
Then I added this:
<object id="geoServiceWCF" type="ExampleProj.Web.WebServices.GeoServiceWCF" singleton="false" >
</object>
<object id="GeoServiceWCFServiceHost" type="Spring.ServiceModel.Activation.ServiceHostFactoryObject, Spring.Services">
<property name="TargetName" value="geoServiceWCF" />
</object>
...I got the following exception:
Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are []. (Error creating object with name 'GeoServiceWCFServiceHost')
And here's my Web.Config part for WCF:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="AJAXFriendly">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="geoServiceWCF">
<endpoint address=""
behaviorConfiguration="AJAXFriendly"
binding="webHttpBinding"
contract="ExampleProj.Web.WebServices.IGeoServiceWCF" >
</endpoint>
</service>
</services>
</system.serviceModel>
Scenario 2:
If I define address="http://localhost/ExampleProj/WebServices/GeoServiceWCF.svc" as the exception suggest, I get another error: The HttpGetEnabled property of ServiceMetadataBehavior is set to true and the HttpGetUrl property is a relative address, but there is no http base address. Either supply an http base address or set HttpGetUrl to an absolute address. (Error creating object with name 'GeoServiceWCFServiceHost')
Scenario 3:
Then, if I set httpGetEnabled="true" I get an Access denied error.
More info: some problem trying to register the URL address http://+:80/ExampleProj/WebServices/GeoServiceWCF.svc/ (yes, with the "+" symbol)
Summary
I follow the so-simple steps from the Spring.NET doc. I think I'm missing something because
I cannot believe I had to set up so many weird parameters to make it work.
Sorry for the long question, I wanted to provide as much info as possible.
Thanks in advance!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用的是 *.svc 文件,则必须更新它以配置要使用的自定义工厂:
然后,您不需要在容器中定义“GeoServiceWCFServiceHost”对象。这就够了:
If you are using a *.svc file, you have to update it to configure the custom factory to use :
Then, you don't need to define the "GeoServiceWCFServiceHost" object in the container. This is enough :