开发者

WCF 3.5 Service and multiple http bindings

I can't get my WCF service to work with more than one http binding.

In IIS 7 I have to bindings http:/service and http:/service.test both at port 80.

In my web.config I have added the baseAddressPrefixFilters but I can't add more than one

<serviceHostingEnvironment>
    <baseAddressPrefixFilters>
        <add prefix="http://service"/>
        <add prefix="http://service.test"/>
    </baseAddressPrefixFilters>
</serviceHostingEnvironment>

This gives almost the same error

This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.

as if no filers were specified at all (This collection already contains an address with scheme http. There can be at most one address per scheme in this collection. Parameter name: item)

If I add only one filter then the service works but only responds on the added filter address.

I've also tried with specifing multiple endpoints like (and only one filter):

<endpoint address="http://service.test" binding="basicHttpBinding" bindingConfiguration="" contract="IService" />
<endpoint address="http://service" binding="basicHttpBinding" bindingConfiguration="" contract="IService" /> 

Then still only the address also specified in the filter works and the other returns this error:

Serve开发者_如何学运维r Error in Application "ISPSERVICE" HTTP Error 400.0 - Bad Request

Regards Morten


I was trying to deploy a WCF service to one of my web servers the other day and ran into a problem. I kept getting the following error message:

This collection already contains an address with scheme http. There can be at most one address per scheme in this collection.Parameter name: item

The problem didn't happen on my local machine but did on the web server making it a little difficult to figure out what was causing it. It happened on the server because my web server is in a shared hosting environment in which case the WCF service also needs to know the host header. To do this I navigated to <system.serviceModel> in the web.config and added the following:

<serviceHostingEnvironment>
<baseAddressPrefixFilters>    
    <add prefix=http://MyHostHeader />
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜