开发者

WCF WebService with Spring.NET could not find base address scheme http

开发者 https://www.devze.com 2023-03-14 21:15 出处:网络
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 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.开发者_如何学GoserviceModel>

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!!


If you are using a *.svc file, you have to update it to configure the custom factory to use :

<%@ ServiceHost Language="C#" Debug="true" Service="geoServiceWCF" Factory="Spring.ServiceModel.Activation.ServiceHostFactory" %>

Then, you don't need to define the "GeoServiceWCFServiceHost" object in the container. This is enough :

<object id="geoServiceWCF" type="ExampleProj.Web.WebServices.GeoServiceWCF" singleton="false" >
</object>
  • Bruno
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号