I am a new developer in an academic environment working on a project for
graduation. I appreciate any help anyone can give me!
I have tried to use good programming techniques and split up my application
into different tiers: Win (windows client), WS (web service), DAL (data
access layer), and Common (where i store all of my common classes and data
sets).
I have a class in my Common tier that is called User. It has some members
and also has two functions in it.
I have a web method called GetUser() and it returns a value of type
Common.User.
In my Win application I want to consume the web service and return a user of
the Common.User type such as this example:
Dim CurrentUser as new Common.User
CurrentUser = CType(UsersWS.GetUser(), Common.User)
My problem comes because I am getting an error in the conversion: [Value of
type 'UsersWS.User' cannot be converted to 'Common.User']. This is really
frustrating because if I make the CurrentUser variable of type UsersWS.User,
then I can't use the functions that I have built into the Users class, only
the data members.
I have thought of everything and even changed my declaration of the class
User in my Common Tier to:
<Serializable()> Public Class User : Inherits System.MashalByRefObject
so that an object of this type could cross application domains.
--I'm not sure what to do at this point but I would love for that conversion
to work. Maybe I am just missing something simple (hopefully!).
Anyhow, thanks for any help!
Ed
sancerre - 28 Oct 2004 19:19 GMT
Ed,
I noticed that you still haven't received any replies (it isn't a
terribly active news group, is it?).
I'll give a shot at explaining your situation. The class Common.User
is getting serialized into XML by the Web service. In order to use the
xml as a strongly typed Common.User, you'll need to convert the Xml
back into the desired object. Alternatively, you can declare an XML
based User, which can be exposed by the Web service and published in
the WSDL.
If that sounded a bit confused, here is a short version: the Web
service does not return back Common.User, it returns back a WS.User -
which is not the same object!
By the way, why have you chosen an SOA architecture? Are you planning
on other consumers of your business logic?
-- Sancerre
MisterEd - 29 Oct 2004 01:09 GMT
Thanks for the help. I see the situation. I am just going to have to make
due with the class WS.User generated by the proxy.
I am using SOA because some of our users may take their application home and
need to connect outside of our firewall. I figured this was the best
approach since we could not open the SQL Server port on the firewall.
Ed
> Ed,
>
[quoted text clipped - 16 lines]
>
> -- Sancerre