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 / July 2006

Tip: Looking for answers? Try searching our database.

How to Persist Custom Class to Web Client?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
samtilden@gmail.com - 28 Jul 2006 16:06 GMT
I made my own class, MyCompany.MyClass and I want to send one object of
this class from my webservice to the client.

On the client side, when I Update Web Reference, the object is known as
ProjectName.localhost.MyClass and not MyCompany.MyClass and the C# code
cannot cast from one to the other.

I can manually go into Reference.cs and tell the client side to expect
MyCompany.MyClass, but each time I do an Update Web Reference, my
manual change is wiped out (as expected).

Is there some attribute, flag, configuration setting I need to set in
order for the client to expect the correct class?

Thanks.
Pablo Cibraro [MVP] - 31 Jul 2006 15:12 GMT
No, VS or the wsdl.exe tool always create a new class from the type exposed
in the WSDL. (The class used as parameter in the web service, in your case,
MyCompany.MyClass). That happens because the web service can be implemented
in any platform, not only .NET.
Anyway, both classes represent the same XML, so if you use the generated
class in the client, the service will receive a MyCompany.MyClass instance.
(.NET performs the XML serialization and derialization for you, that process
is completely transparent).
In that way, the client application and the web service are loose-coupled by
types.
Your client application should use that generated class and not the original
one (MyCompany.MyClass) in order to consume any web service with the same
WSDL.

Regards,
Pablo Cibraro
http://weblogs.asp.net/cibrax

>I made my own class, MyCompany.MyClass and I want to send one object of
> this class from my webservice to the client.
[quoted text clipped - 11 lines]
>
> Thanks.

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.