Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / June 2004

Tip: Looking for answers? Try searching our database.

Server defined objects

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DalePres - 12 Jun 2004 03:10 GMT
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
DalePres - 13 Jun 2004 22:30 GMT
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

> 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
[quoted text clipped - 28 lines]
>
> Dale

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.