Monday, January 14, 2013

Be cautious! Name your WCF operation contract right


..  and attach a distinct and  meaningful name.


When publishing metadata for a service that exposes two different service contracts in which each contain an operation of the same name an exception is thrown. 

For example, if you have a service that exposes a service contract called ICarService that has an operation Get(Car c) and the same service exposes a service contract called IBookService that has an operation Get(Book b), an exception is thrown or an error message is displayed when generating the service's metadata. 

To remedy this issue you may want to consider one of the following approach:
  • Rename one of the operations. I'd suggest give them some meaningful name, any way (such as GetCar(Car car) and GetBook(Book book))
  • Set the operation Name to a different name
  • Set one of the operations' Namespaces to a different namespace using the Namespace property


No comments:

Post a Comment