PDA

Click to See Complete Forum and Search --> : Multiple classes within a webservice


ComputerJy
Jul 10th, 2007, 08:09 AM
Hi all,

I was just wondering if I can include multiple inner classes within a web service and still be able to access them using HTTP.
If it's doable then is it as simple as any other inner class or are there any attributes, notations that the service class should have
I'm doing something like:[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{
public Service() { }
public class ArtService
{
....
}

All help is appreciated.
Thanks

XYZ-R
Jul 15th, 2007, 12:36 PM
Typically a single class is exposed to callers as a single web service (using the System.Web.Services.WebService attritube). The web method attribute, as you know, is then used to expose the classes' methods to service callers. Methods without this attribute cannot be seen by service consumers, even if they are declared Public. Of course other "worker" classes can sit in your project, but they will not be visible to callers.

Also, I know that you can use inner classes in C# (and I assume VB.NET) but am not sure if you can successfully apply the web service and web method attributes to the class or its methods... A quick test should tell you...

Regards,
Tim

mendhak
Jul 27th, 2007, 11:34 AM
Have your webmethods return these custom classes but bear in mind that they ought to be serializable and your calling client must know about those classes. Which means that they both need to reference the same class library containing such definitions and that is... uhm... yeah.