需要有关WebService继承的帮助 [英] Need help on inheritance with WebService

查看:74
本文介绍了需要有关WebService继承的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个.NET 2.0 WebService,它包含一个派生自System.Web.Services.WebService的基类webserivce(我们称之为wsBaseClass1)。  wsBaseClass1包含一个名为TestMethod的WebMethod。 我有多个派生自wsBaseClass1的WebService类。 为了简单起见,我们假设有两个派生类&wbspDerivedClass1和wsDerivedClass2。 这两个类都派生自wsBaseClass1。

我想在客户端上使用Web服务来实例化wsDerivedClass1和wsDerivedClass2,但是使用基类数组(wsBaseClass1)作为用于接收实例化对象的对象。 因此,我希望能够使用抽象在两个派生类上调用基类WebMethod(TestMethod)。 

目前,当我添加WebReference时,references.cs文件只包含派生类而不包含基类。 派生类在其定义中嵌入了基类WebMethod(TestMethod)。 这不允许我做我想做的抽象。 有人可以建议我如何按照我希望的方式工作或者甚至可以使用它吗?

I am building a .NET 2.0 WebService that contains a base class webserivce (we will call it wsBaseClass1) that derives from System.Web.Services.WebService.  wsBaseClass1 contains one WebMethod called TestMethod.  I have multiple WebService classes that derive from wsBaseClass1.  just for simplicity sake, let's say there are two derived classes wsDerivedClass1, and wsDerivedClass2.  Both of these classes derive from wsBaseClass1.

What I would like to do on the client that consumes the web service is to instantiate wsDerivedClass1 and wsDerivedClass2, but use an array of base class (wsBaseClass1) as the object to receive the instantiated objects.  Thus, I want to be able to call the base class WebMethod (TestMethod) on both derived classes using abstraction. 

Currently, when I add the WebReference, the references.cs file contains only the derived classes and not the base class.  The derived classes have the base class WebMethod (TestMethod) embedded within their definition.  This does not allow me to do the abstraction that I would like to do.  Can someone please recommend how I can get this to work the way I want it to work or if it is even possible?

推荐答案

"添加网页参考"不像这样工作。它不保留Web服务类之间的任何派生。 
"Add web reference" does not work like this. It does not preserve any derivation between web services classes. 


这篇关于需要有关WebService继承的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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