Web服务中的多个需求 [英] Multiple Clasess in a Web Service

查看:60
本文介绍了Web服务中的多个需求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hei All,

我想创建一个具有多个类的Web服务,但无法访问它们.

我只能访问主类.还有什么其他方法可以访问其他类.

我要这个

在Web服务中,我有两个类

Hei All,

I want to create a Web Service with multiple classes but can''t access them.

I can access only the main class. Is there any other way to access other class.

I want this;

in web service I have two classes

class a {..... }
class b {..... }



在我的服务引用中,我想像这样访问这些类:



in my service ref I want to access these classes like this:

webServiceRef.a myA = new webServiceRef.a();
a. ....
a. ...
.
.



任何想法.

谢谢



Any idea.

Thanks

推荐答案

你好朋友
您对Web服务有一些错误的主意.
请参考这个...

您的第一个C#Web服务 [ ASP.NET Web服务 [什么是Web服务? [
Hello Friend
you have some thing wrong idea about web service..
please refer this...

Your first C# Web Service[^]
ASP.NET Web Service[^]
What is Web Service?[^]

And what you need is that you have created two classed named A and B and you want to access that class method or variable declared inside that class...

so first of clear in your mind that you can access a web method declared inside your web service..

so for accessing method declared inside class A you need to declare a web method that will call that method declared inside class A like this you need to call your class method...

and there is no limit to declare multiple classes inside web service...


call your method like this...

Inside Web service declare web method

[Web Method]
public void callAMethod()
{
    A obja = new A();
    return obja.Display();
}


Class A
{
  public void Display()
  {
     // Your Method Code goes here...
  }
}


这篇关于Web服务中的多个需求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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