Re: ASP .NET 2.0 web service beginner question - Multiple classes



<crowl@xxxxxx> wrote in message news:688236b8-42c6-4847-9db7-a7fbb6499994@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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

.



Relevant Pages

  • RE: SOAP .Net client wrapper questions
    ... on the client side or the web service side? ... for the web service and that didn't produce any result. ... automatic Proxy setting detection, and that seems like it might be involved. ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.webservices)
  • 1st invocation of Web Service from client is very slow - solution?
    ... people complaining that 1st invocation of a Web Service can be very ... writing the client proxy yourself). ... remote methods do not change signature, and get the proxy to compile ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: ISA Server Problems, please help
    ... The All access rule for SBS Internet ... Web Proxy and/or ... > To accommodate the linux SecureNAT clients you should create a new Client ... ISA Server denies the specified Uniform Resource Locator. ...
    (microsoft.public.windows.server.sbs)
  • Re: Attachments.Add - Object reference not set to an instance of an object.
    ... webservice projects in a signle solution, Visual Studio does not create the ... webservice to the client project; ... Visual Studio created the proxy ... > Enable Microsoft Web Service Enhancement SOAP Extension are checked. ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Need to Turn Off Proxy Server in SBS 4.5
    ... client machines (it is done by default when you install an SBS client)? ... IE's web proxy settings are disabled like you said, ... Server is internal only...no outside web or ftp serving. ...
    (microsoft.public.backoffice.smallbiz)

Loading