I have an existing WCF service. At some point, sometimes an [OperationContract]
or a [DataMember]
in a data contract becomes [Obsolete]
. I don't want to remove the method, for back-wards compatibility reasons. Another example is sometimes I have an Enum, and want to [Obsolete]
one of the choices, but I can't completely remove it because items already exist in the system / database that contain that value.
Anyway, is there a way to omit certain items from the generated WDSL? For example:
[ServiceContract]
public interface IMyService
{
[OperationContract]
string SomeMethod(string x); // I do want this in the WSDL
[Obsolete]
[OperationContract]
string OldMethod(string x); // I do NOT want this in the WSDL, but I do want it to still work / be callable if an older system tries to call it.
}
There isn't anything out-of-the-box which can be used to do that, but you can use a WSDL export extension to remove some of the operations from the service metadata. I implemented a sample for this scenario at http://blogs.msdn.com/b/carlosfigueira/archive/2011/10/06/wcf-extensibility-wsdl-export-extension.aspx.
WCF is pretty versioning tolerant within some constraints as documented in this MSDN article. It's probably too late for your current service to adopt some of these practices but you can accomplish what you want by creating new ServiceContract interfaces that remove the operations and enums you need hidden.
You would also need to create a new endpoint for the new the interface. The same service implementation can support multiple interfaces with a little tweaking so the changes shouldn't be too extensive. Any new clients would use the new service endpoint while the the old clients would use the original endpoint.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With