Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
class a {..... }
class b {..... }


in my service ref I want to access these classes like this:
C#
webServiceRef.a myA = new webServiceRef.a();
a. ....
a. ...
.
.


Any idea.

Thanks
Posted

1 solution

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

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


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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900