WCF client using multiple services

I am trying to figure out how to configure my web.config (client) to consume two different WCF web services, one using the other using buttons

I have two endpoints, I think I need two different binding configurations. This is my current node binding:

<basicHttpBinding> <binding name="WebServiceProxyServiceSoapBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:01:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="Transport"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> 

I cannot add another basicHttpBinding node. The fact is that if EVERYTHING, I changed, was a mode parameter in <security mode="Transport"> , then the binding will work fine for one or the other endpoint.

This seems like a common problem, but could not find an answer. In general, I am not very worried with WCF (if this is not obvious) beyond simple consumption and challenge. Any help would be GREAT!

This article was a close, but not quite the same problem, because they did not need a different security mode: How to use multiple WCF services in one client

Thanks in advance.

+6
source share
2 answers

You just need to add another <binding> node with a different name and any other parameters you like in the <basicHttpBinding> node section.

Then, obviously, just make sure that each client is configured to use a binding specific to them by setting the corresponding name in the bindingConfiguration attribute for each <endpoint> node.

+6
source share

I have two endpoints, I think I need two different configuration bindings. This is my current node binding:

Not necessarily - if these two services use the same settings and the same protocols, the same binding configuration will work.

What you need to add two of them is the client element:

 <system.serviceModel> <bindings> ..... (as you already have it) .... </bindings> <client> <endpoint name="Service1Endpoint" address="http://yourserver/service1.svc" binding="basicHttpBinding" bindingConfiguration="WebServiceProxyServiceSoapBinding" contract="IWCFService1" /> <endpoint name="Service2Endpoint" address="http://yourserver/service2.svc" binding="basicHttpBinding" bindingConfiguration="WebServiceProxyServiceSoapBinding" contract="IWCFService2" /> </client> </system.serviceModel> 

That should do.

Of course, if your second service uses a different binding or needs different security settings, then yes, you need to add a second <binding name="something else" .....> under your <basicHttpBinding> node and refer to the second binding configuration from one of your two client endpoints.

+1
source share

All Articles