simon.smith
9/1/2003 12:40:00 PM
"Wor Tony" <anthony@anthonypounder.SHOES.com> wrote in message news:<OIRDDGCaDHA.736@TK2MSFTNGP09.phx.gbl>...
> "Sam Vanhoutte" <sam_vanhoutte@hotmail.com> wrote in message
> news:eA4GHmYZDHA.2256@TK2MSFTNGP10.phx.gbl...
> >
> > "Henke" <henke_nord@hotmail.com> wrote in message
> > news:%23hWlq7VZDHA.2284@TK2MSFTNGP12.phx.gbl...
> > > Can the classes have any methods or am I stuck to creating clases with
> > > public properties, only?
> > > /Henke
> > >
> > The classes can have methods, but these methods are not serialized, as
> they
> > never contain state...
> > Clients need to have objects with the same properties, but they don't need
> > to have these methods...
> >
> Yep. As Sam has already said, no methods, just public properties.
>
> If you create an xsd, then the client and your web service can validate the
> objects using
> schema validation.
>
> HTH
>
> AP
> Nottingham - UK
The way to do this is:
First create the classes you want to send in a separate assembly. In
the Web Service project reference that assembly and construct and
return the class you want.
In the Client project reference the assembly containing the class(es)
you want to sent. Then create (or update) the Web Reference.
Now open up the Reference.cs associated with the Web reference. At the
bottom you will find a class definition containing the fields og the
class as public fields. DELETE THIS BIT OF CODE!
At the top of the Reference.cs add a 'using' for the assembly which
contains the passed class, and add the same using wherever you call
the Web Service. Compile. Go.
If later you update the Web reference the deleted class definition
will be reinstated and the client will not compile. Fine. Go back and
delete the generated class definition and add the using to the
Reference.cs and all will be OK.
HTH