Webservice从另一个Webservice继承 [英] Webservice Inherit from another webservice

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

问题描述

大家好,

我无法从另一个Web服务继承.

任何人都可以这么友好地向我解释如何做.

我想要实现的是从另一个Web服务继承到我的Web服务中,并且当我在浏览器中查看该Web服务时能够看到该Web服务的方法.

例如.

我在htpp://localhost/example1/a.asmx上有一个Web服务.接下来,我要创建Web服务b并将Web服务a用作基类,并能够覆盖和使用其方法.

感谢您的帮助.

亲切的问候

Terence

Hi Guys,

I am having trouble with inheriting from another web service.

Could anyone please be so kind to explain to me how to do it.

What i want to achieve is to inherit in my web service from another web service and be able to see methods of that web service when i view it in a browser.

For example.

I have web service a at htpp://localhost/example1/a.asmx. Next i want to create web service b and use web service a as a base class and be able to override and use its methods.

Thanks for the help.

Kind Regards

Terence

推荐答案

在b.asmx的代码背后,将类声明修改为如下所示:

In the codebehind of b.asmx, amend the class declaration to look something like this:

public class b : a
{
//overrides etc. here
}


如果您不拥有要继承的Web服务的代码,请从Web Service WSDL创建代理类

*打开Visual Studio命令提示符
* WSDL [
If you don''t own the code for the web service you want to inherit from, then create a proxy class from the web service WSDL

* Open visual studio command prompt
* WSDL[^] /out:C:\myProxyClass.cs http://localhost/example1/a.asmx?WSDL

That will generate a proxy class with all the web service methods that are in the service a.asmx

Include the file generated at C:\myProxyClass.cs in the project where you want to override it.

Now inherit a class as stated by Jim

public class MyDerivedClass : ProxyClass 
{   
}



对于要覆盖的方法,您需要进入代理类的源代码并将这些方法标记为virtual



For methods that you want to override, you''ll need to go into the source code of the proxy class and mark the methods as virtual


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

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