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 / November 2005

Tip: Looking for answers? Try searching our database.

Inheriting Consumed WebService Class

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Paul Whygle - 04 Nov 2005 17:58 GMT
Is it possible to inherit a class that is a part of a Consumed Webservice?
I have been trying to get this to work and i cant seem to figure it out.
When i look at the "code-behind" (for lack of a better word) for my consumed
webservice, it is just showing public variables for my properies in the
original class.  ex:  WebService has a class Customer.  Customer has a
property (public virtual string FirstName { get {return firstName;} set {
firstName = value; } }.  I consume the Webserive and when I look at the code
for that Webservice is just shows public string FirstName;
I want to inherit from this class, but they way it brings over the code, i
cannot.  any ideas?  Or am I trying to do the impossible?
Thanks in advance!

Paul
Peter Kelcey - 04 Nov 2005 22:27 GMT
Paul

The first thing to remember is that your proxy class (i.e. what you've
called the consumed webservice code-behind file) is generated from your
service's WSDL and not directly from your C# class.  When you create
your web reference, your proxy class is generated from the WSDL's XML
and is therefore limited to what is defined in that XML. If you look at
the WSDL you will see that there is no reference to class properties,
gets, sets etc.

The second thing to remember is that when you make your web service
call, you are not actually marshalling up actual instance of your class
and sending it across the wire back you client. What you are doing is
serializing your class into XML and sending that XML back to your
client. What you are getting on the client side is an XML snapshot of
your customer class as it exists at the time of service call.  Because
you are only getting a snapshot, you don't get any of the methods in
the class or any else in the way of functionality. You are only able to
access the properties in the class via the public variables.

In order to have full access to class method, propeties etc, what I
would recommend doing is creating your customer class in a separate
project that you will reference from both your web service and your
client application. By doing that, both projects will have full access
to your class, its methods, its overridable properties etc.

Next,  create (in the client project) the new superclass that will
inherit from your base customer class.

Next, create the web reference from your client to your service. In
your auto-generated proxy class, manually change any references to the
base customer class (which will be defined further on in your proxy
class) with a reference to the new superclass you just created.

At that point, you will be able to retrieve a fully functionaly class
from your proxy that will have your methods, properties etc in it.

Hopefully that wasn't too confusing. If it was, let me know and I will
post back some code examples from a sample project I have.

Hope that helps,

Peter Kelcey
Paul W - 08 Nov 2005 03:56 GMT
Hey Peter,
This was actually incredibally helpful....however, some example code (as
simple as you feel would be helpful) would be greatly appreciated.
Thank you so much for your time and help!!!
Paul
> Paul
>
[quoted text clipped - 39 lines]
>
> Peter Kelcey

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.