简体   繁体   中英

wsHttpBinding changes to basicHttpBinding in client app.config

In a WCF service I have an endpoint binding set as wsHttpBinding. However when I use Visual Studio to Add Service Reference my clients app.config shows the binding as basicHttpBinding. Does anybody know why this may be happening?

My Endpoint in the service web.config (hosted in IIS 7.5). Gets address from baseAddresses

<endpoint address=""
    binding="wsHttpBinding"
    bindingConfiguration="wsHttpServiceBinding"
    contract="MyProject.IMyService" />

Client app.config:

<client>
    <endpoint address="http://example.com/MyService.svc"
    binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_MyService"
    contract="Service.MyService" name="BasicHttpBinding_MyService" />
</client>

-- Ladislav Mrnka pointed me in the right direction with this. Thanks very much.

I tried to keep the question simple as I thought the answer may be straight forward. However I should have explained my set up in a little bit more detail as this is where the answer to my problem lay.

Instead of having my service contract (IMyService) residing in my WCF Service Application I had it in another Domain project where I keep all my interfaces so that they can be reused throughout many different projects. In my WCF Service Application .web.config I had the service name pointing at the interface project rather than at the implementation. This caused VS2010 (svcutil.exe) to create a proxy and config based on default settings (I presume reside in the machine.config (for WCF 4)).

So to summarise for anybody else who may come across this issue it was service name pointing to the wrong location. Ensure that the service name points to the implementation (usually in the WCF Service Application - MyProject.MyService) and that the endpoint contract points to the service contract (In the WCF Service Application or external project - MyProject.IMyService or AnotherProject.Interfaces.IMyService).

Thanks for all your help.

In my case, I made the following changes to my App.config

<service behaviorConfiguration="Throttled"  name="Registrar.Services.RegistrarPaperService">
                <endpoint address="" binding="wsHttpBinding" bindingConfiguration="PapersBinding"
                    contract="Registrar.Services.IRegistrarPaperService" />
                <endpoint address="mex" binding="wsHttpBinding" contract="IMetadataExchange" />
            </service>

In name attribute of the service I gave the complete namespace and class name where I have service implementation and in the contract, I have complete name space and Interface name.

My Service Implementation namespace is this Registrar.Services.RegistrarPaperService My Interface Registrar.Services.IRegistrarPaperService

IF you put both the service and its interface in the same namespace it will solve many issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM