"twahl" <tw***@discussions.microsoft.comwrote in message
news:B0**********************************@microsof t.com...
Hi,
In the WS I've defined a class that contains both data and methods. I'm
trying to pass this class to a client application using a web method.
When I
access this class on the client only the properties are available not the
methods. I guess this makes sense but how can I get access/instantiate to
the complete class containing both the data and the methods?
You can't. Web Services don't work that way.
What happens is that there is a class on the server. For the sake of
discussion, let's call it "Employee". Emplyee has properties like ID and
Name and DateOfBirth. It has methods like Hire and Fire and Pay.
The client calls an operation on your web service, and you want to send an
Employee back. Your web service acquires an instance of the Employee class.
This instance gets serialized into the response to the web service
operation.
All that gets serialized is the data. Only XML, which conforms to the schema
which is a part of the WSDL file describing your web service.
The client receives this XML. Most clients will deserialize this into an
instance of a class, which may happen to be called "Employee". That need not
be the case. The client platform could choose to use a class called
WEBSERVICEMPLOYEE if it likes. It's also useful to keep in mind that not all
clients are object oriented!
All the client was sent was XML. The most the client can receive is data
which is deserialized from this XML. No methods were transmitted, so none
were received!
If you need your .NET Client and .NET Server to use the actual, identical
class, then you need to use .NET Remoting, not Web Services.
John