views:

30

answers:

1

I have a versioning issue with a WCF service contract in which one of the many endpoints which are called for the operation is missing one method from the contract.

My question is, how can I make sure the command is available on the client before attempting to call it?

I tried:

  foreach (var od in proxy.Endpoint.Contract.Operations)
  {
    if (od.Name == "MyMethodName")
    {
      hasMethod = true;
      break;
    }
  }

Unfortunately, this is using the contract from the calling app and does not actually describe the implementations on the endpoint itself. As a result, it returns true even though the endpoint has failed to implement the command.

+2  A: 

You'll never actually know until you try it. What you have is a proxy of the implemented contract, but what is on the server side could have changed since you created/generated it.

Assuming it's an http/httpws implementation I suppose you could call and check the service reference and download the wsdl file. That will tell you what methods etc are supported. The problem you're going to have is that even though the name of the method maybe the same, you'll also have to check the return type and parameters to really be sure that it's the same method and that you can call it with the proxy you currently have.

Here is a link on versioning in WCF:
http://msdn.microsoft.com/en-us/library/ms731060.aspx

Here is a link on versioning best practices for WCF:
http://stackoverflow.com/questions/36999/best-practices-for-versioning-your-services-with-wcf

Kevin
Thanks. Unfortunately, we're in a sort of reversed scenario here. The clients were provided with the interface and asked to implement it with a service. We as the host are calling them (this one endpoint), and as such, we do not have the ability to implement versioning for the new methods since they are the server in this case, not us.Also, I think we've been setting up our services to serve Mex only to generate the initial proxies via svcutil. We don't push the Mex configurations to production.
alord1689