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 / General / June 2007

Tip: Looking for answers? Try searching our database.

an architecture based on webservice

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Francesco Spegni - 19 Jun 2007 10:44 GMT
hi there,

i hope this message is not out of topic. i've a question about how to
realize a small architecture based on webservice and whose goal is
ensure a good level o flexibility of my code.

in a few words: i've a webservice which exports the method
Authenticate(User usCurrUser). the data type User should be an
abstract class like this:

public abstract class User
{
 public abstract bool Validate();
}

what i wish to do would be to create a subclass of it like

public abstract class UserSub : User
{
 public UserSub(string strUserId, string strPassword)
 {
   ...<the actual code>...
 }

 public override bool Validate()
 {
   ...<the actual code>...
 }
}

and pass an istance of the subclass to the webservice. the behavior i
expect is that the webservice, calling the abstract method Validate(),
will indeed call the Validate() method specified in the UserSub
class.

why all this? i guess you can easily imagine that if i'm able to
realize this i can change the way to authenticate my users (let's say
no more by userid and password but, instead, by fingerprints) without
need to change the proxy through which my client application calls the
webservice. i "just" need to change the webservice code and the client
code.

i've googled a bit, but i still cannot figure how to realize an
architecture like this. does any of you have some suggestion for my
problem?

i thank you in advance for any help you can give me,

have a nice day :)

francesco
John Saunders [MVP] - 19 Jun 2007 14:02 GMT
> hi there,
>
[quoted text clipped - 30 lines]
> will indeed call the Validate() method specified in the UserSub
> class.

Francesco,

You can't do this with web services. They deal in data only. They cannot
pass instances of an object with methods. Consider the following:

public class UserBase
{
   public virtual string SomeMethod()
   {
       return "UserBase";
   }
}

public class UserDerived : UserBase
{
   public override string SomeMethod()
   {
       return "UserDerived";
   }
}

[WebService]
public class MyUserService
{
   [WebMethod]
   public void UserBase GetUser(int userID)
   {
       // look up user
       // return user
   }
}

-----------
On the client:

using (MyUserService service = new MyUserService())
{
   UserBase user = service.GetUser(1);
   Console.WriteLine(user.SomeMethod());    // Will not compile - no such
method
}

This will not compile because the client proxy class only reflects the
"data" portion of the UserBase and UserDerived classes. The data are
described by XML Schema that is referenced by the WSDL (Web Service
Description Language) that .NET generates from the web service. But there is
nothing in WSDL or XML Schema that can describe class methods (except for
the methods of a web service).

You could accomplish what you want through .NET remoting, if remote
operation is part of your requirements.
Signature

John Saunders [MVP]


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.