wsHttpBinding changes to basicHttpBinding in client app.config
Asked Answered
T

2

5

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>
Twittery answered 4/1, 2011 at 21:1 Comment(2)
Most probably your configuration is not used and your client is built from default configuration. Check that name in your service element is same as service type in ServicHost directive (.svc file) including namespaces. You can also verify this in WSDL.Rodroda
I did not mention this in post as was trying to keep it simple but I have two bindings, the other being net.tcp which comes through without any issues, hence my confusion.Twittery
T
8

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

Twittery answered 5/1, 2011 at 17:56 Comment(0)
D
0

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.

Doubledecker answered 4/1, 2023 at 7:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.