Search code examples
wcfwcf-client

WCF service contract name mismatch between client and server sides


I was trying to integrate my Web application with two WCF services provided with the same Service Contracts names but in two different addresses. The thing is I want to create proxies for both services within one DLL, but that was not doable as both contracts hold the same name, I tried to use like nested name spaces, also it didn't work as the proxies are hosted in a separate DLL other than the web project, I changed the name of one service contract, but I got this error:

The message with Action 'http://ws.aramex.net/ShippingAPI/v1/RateCalculateService/CalculateRate' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

Is it possible by any means to have different contract name in client side than the one in the server?

endpoints:

<client>
      <endpoint address="http://ws.dev.aramex.net/shippingapi/shipping/service_1_0.svc"
          binding="basicHttpBinding" bindingConfiguration="basic"
          contract="Service_1_0" name="BasicHttpBinding_Service_1_0" />

      <endpoint address="http://ws.aramex.net/shippingapi/ratecalculator/service_1_0.svc"
         binding="basicHttpBinding" bindingConfiguration="basic"
         contract="RateCalculateService" name="BasicHttpBinding_Service_1_0" />
    </client>

The original contract name of the second endpoint was "Service_1_0"


Solution

  • I was trying to integrate my Web application with two WCF services provided with the same Service Contracts names but in two different addresses.

    You say the same Service Contract names? Do you mean the service contracts are identical?

    If so, why not just specify two endpoints with different names and the same contract:

    <client>
        <endpoint address="http://ws.dev.aramex.net/shippingapi/shipping/service_1_0.svc"
          binding="basicHttpBinding" bindingConfiguration="basic"
          contract="Service_1_0" name="BasicHttpBinding_Service_1_0_Instance1" />
    
          <endpoint address="http://ws.aramex.net/shippingapi/ratecalculator/service_1_0.svc"
             binding="basicHttpBinding" bindingConfiguration="basic"
             contract="Service_1_0" name="BasicHttpBinding_Service_1_0_Instance2" />
    </client>
    

    Then specify the endpoint name (BasicHttpBinding_Service_1_0_Instance1 or BasicHttpBinding_Service_1_0_Instance2 for the above example) as the parameter endpointConfigurationName to the appropriate proxy class constructor overload.