In WCF, is there a way to omit / hide a ServiceOperation or a DataMember from the WSDL?

前端 未结 2 1424
孤街浪徒
孤街浪徒 2021-01-13 11:48

I have an existing WCF service. At some point, sometimes an [OperationContract] or a [DataMember] in a data contract becomes [Obsolete]

相关标签:
2条回答
  • 2021-01-13 11:58

    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.

    0 讨论(0)
  • 2021-01-13 12:04

    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.

    0 讨论(0)
自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题