ASP .NET 2.0 web service beginner question - Multiple classes

Discussion in 'ASP .Net Web Services' started by crowl@gmx.de, Oct 10, 2008.

  1. Guest

    I followed a few "Hello World" examples for asp web service and it
    works fine. Now I want to provide the clients multiple classes they
    can work with, lets say Class1, Class2, Class3.

    I have created a new asp.net web service project in VS and it created
    Service.asmx with

    public class Service : System.Web.Services.WebService ...

    Now I have added 3 Classes (Class1, Class2, Class3) by using -> Add
    New Item ..., added properties and methods. All compiled well, but if
    I tried to use (find) the classes in the client application there is
    only the Service object nor other objects to work with. What I have to
    do that Class1, Class2 and Class3 is also available at the client?
    , Oct 10, 2008
    #1
    1. Advertising

  2. <> wrote in message
    news:...
    > I followed a few "Hello World" examples for asp web service and it
    > works fine. Now I want to provide the clients multiple classes they
    > can work with, lets say Class1, Class2, Class3.
    >
    > I have created a new asp.net web service project in VS and it created
    > Service.asmx with
    >
    > public class Service : System.Web.Services.WebService ...
    >
    > Now I have added 3 Classes (Class1, Class2, Class3) by using -> Add
    > New Item ..., added properties and methods. All compiled well, but if
    > I tried to use (find) the classes in the client application there is
    > only the Service object nor other objects to work with. What I have to
    > do that Class1, Class2 and Class3 is also available at the client?


    None of your server-side classes will ever be available on the client. Your
    "Service" class is not available on the client. Don't believe me? Add a
    private method to your "Service" class, and then go update the web reference
    on the client and see if the private method show up there.

    In fact, if you go look at the "Service" class that the client uses, you'll
    see that it is totally different from what you wrote on the server. It
    happens to have some of the same method names as your server-side class. The
    signatures of those methods happens to be similar, or maybe even the same.
    But the methods themselves are totally different.

    That's because the client has a Proxy version of "Service", not the real
    thing. The proxy class is for the purpose of calling your real "Service". It
    keeps the client from having to manipulate XML and handle the underlying
    protocol stuff needed to talk to a web service. The client can pretend that
    it is calling a real method on a real class.

    There are no proxy versions of Class1, Class2 or Class3. That is because
    they are not needed in order to call your service. I bet your service has no
    web methods that take an instance of any of those three classes as
    parameters, nor methods that return an instance of one of those classes.
    Only if they are needed to call the service will a proxy class be created
    for any of your server-side classes.

    Note that these extra proxy classes will not have any methods, events,
    indexers or operations. They will only have properties. That is because this
    is the only thing necessary to communicate with your web service. In fact,
    the proxy classes will not have the "real" properties - they only have
    properties that permit the data to be serialized into XML so that it can be
    sent to your service, or deserialized from XML so that the data can be
    received from your service.

    If you simply have some code that you want a client of your web service to
    be able to call, in order to perform some function that does not directly
    involve your service, then you need to put that into a class library and
    ship the library so that the clients have it. Of course, this won't help
    with clients that are not written in .NET.

    --
    John Saunders | MVP - Connected System Developer
    John Saunders, Oct 10, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    2
    Views:
    1,109
  2. JHenstay
    Replies:
    3
    Views:
    548
    osmium
    Jan 11, 2004
  3. Multiple web service calls from web service

    , Jan 5, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    180
    Rodrigo García
    Jan 9, 2006
  4. Hedley
    Replies:
    1
    Views:
    1,412
    Ram245
    Nov 8, 2013
  5. jazzydance

    asp.net web service connecting to another web service

    jazzydance, Feb 7, 2010, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    809
    Mr. Arnold
    Feb 8, 2010
Loading...

Share This Page