views:

156

answers:

2

I'm trying to figure out how to set up my web.config (the client) to consume two different WCF web services one using the other using

I have the two endpoint, I guess I need two different Binding configurations. This is my current binding node:

<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 can't add another basicHttpBinding node. The thing is if ALL I changed was the mode parameter in <security mode="Transport"> then the binding will work great for one or the other endpoint.

This seems like a common issue, but have not found an answer. Overall I'm not very experiences with WCF (if that is not obvious) outside the simple consume and call. Any help would be GREAT!

This article was close but not quite the same issue as they did not need a different security mode.: http://stackoverflow.com/questions/686112/how-to-consume-multiple-wcf-services-from-one-client

Thanks in advance.

+1  A: 

You just need to add another <binding> node, with a different name and whatever different options you like, under the <basicHttpBinding> node.

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

Drew Marsh
:) That was too easy. Thank you!
SCEV
A: 

I have the two endpoint, I guess I need two different Binding configurations. This is my current binding node:

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

What you need to add two of is a 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 another binding, or needs different security settings, then yes, you'd need to add a second <binding name="something else" .....> under your <basicHttpBinding> node and reference that second binding configuration from one of your two client endpoints here.

marc_s
Aw, I see I was trying to add a second <basicHttpBinding> node, not a second child Binding node! Thank you!
SCEV