如何在 .NET XML Web 服务 WSDL 中隐藏类型继承 [英] How to hide type inheritance in .NET XML web services WSDL

查看:27
本文介绍了如何在 .NET XML Web 服务 WSDL 中隐藏类型继承的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Web 服务,它公开了方法 M(B).这里B:A(B继承自A).我需要对服务消费者隐藏这种继承.消费者不需要知道 A,尽管 B 会有它的属性.我知道我可以编写自己的 WSDL,但是有没有办法让 .NET 自动执行我想要的操作?

I have a web service, it exposes method M(B). Here B: A (B inherits from A). I need to hide this inheritance from the service consumers. The consumers don't need to know about A, although B will have its properties. I know that I can write my own WSDL, but is there a way to make .NET do what I want automatically?

推荐答案

这个问题的回答很好:

如何隐藏类中继承的属性而不修改继承的类(基类)?

简而言之,您可以覆盖属性和方法,以便它们只抛出异常,并装饰"覆盖的版本,将它们标记为过时.但最佳做法是为 Web 服务合同编写一个单独的类.

In short, you can override the properties and methods so that they just throw an exception, and "decorate" the overridden versions, marking them as obsolete. But the best practice would be to write a separate class for a web service contract.

这篇关于如何在 .NET XML Web 服务 WSDL 中隐藏类型继承的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆