return type of web method should be a class object in web service

P

prasannashetye

hello
I want to return more than 1 values from my web method. For this I am
planing to create a class which will have number of properties, will
set properties and return object of that class in my web method. But
question is how the web service user will get access of that class?
Should I define that class in web service itself? any other method? for
example

public class MyService
{
[webMethod]
public Classb myMethod()
{
Classb objClassb = new Classb();
objClassb.Prop1 = "test";
objClassb.Prop2 = "test1";
objClassb.Prop3 = "test2";
return objClassb;
}
}

where should I define "Classb" class?

thanks
 
M

Marc Gravell

To be honest, it doesn't really matter too much, but somewhere near the
web-service would probably be best for your convenience... Classb must of
course be serializable (with read/write properties (or at a push, fields)).

When used via a web-service, the caller will simply see Classb as defined at
the same level as the web-service itself (via the asmx/wsdl), and your
client (via wsdl.exe or wsewsdl.exe) will generate its own copy of the class
from the asmx structure. The caller will not see the original namespace nor
assembly details.

Marc
 
C

Cor Ligthert [MVP]

As you use a non typed dataset than you have in my idea the easiest class to
be used to pass serialized to everywhere but especially in a webservice, you
can use it excluding the scheme and including the scheme.

I hope this helps,

Cor
 
P

prasannashetye

hello
thanks for your help. I will try as per suggestions by both of you.

thanks
 
P

prasannashetye

hello
thanks for your help. I will try as per suggestions by both of you.

thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top