Results 1 to 3 of 3

Thread: Multiple classes within a webservice

  1. #1

    Thread Starter
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Multiple classes within a webservice

    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:
    Code:
    [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
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  2. #2
    Junior Member
    Join Date
    Jan 2004
    Posts
    25

    Re: Multiple classes within a webservice

    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

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Multiple classes within a webservice

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width