Server defined objects

D

DalePres

When I pass a class to a web service as a method parameter, or from the web
service as a return value, I get an error to the effect that .Net cannot
implicitly convert from WebService.MyClass to MyLocalNamespace.MyClass
(substitute usable names). I have set references to MyClass on both the
webforms project and on the web services project and the associated DLL
exists in both projects.

Of course, explicitly casting doesn't help so I have, on small projects,
actually created the server object on the local client. That works pretty
well, but that leads to my main question.

I have a web service, myService, which has a reference to MyClass. I
create, on the webform:

myService.MyClass myClass = new myService.MyClass();

Then I set properties:

myClass.Name = "something";
myClass.Number = 234;

etc.

Each time I set or get a property, does it include a roundtrip to the server
for the definition or is the definition of the MyClass object stored locally
when I created it locally?

The other-than-main question is: Does anyone know a better way to do it?

Thanks in advance,

Dale
 
D

DalePres

Well, I have searched the net, MSDN, and the newsgroups more (for weeks now
really) and still no clear cut examples or descriptions of how to pass a
custom class as a parameter to a WebMethod or receive a custom class as a
return value from a WebMethod. Every article or newsgroup response I was
able to find speaks only in theoretical terms with no specifics or examples.

I finally managed to piece together enough little pieces that I was able to
work it through and produce a working example. I have documented it at
http://www.dalepreston.com/programming/SharedClasses.aspx including source
code.

This is basic so far but for many of us, if we have enough to get started,
we can figure the rest out for ourselves.

I hope this will help others who are working through the same thing.

Dale
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,294
Latest member
LandonPigo

Latest Threads

Top