Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > WS Consumption: CType a return value of class to original class

Reply
Thread Tools

WS Consumption: CType a return value of class to original class

 
 
MisterEd
Guest
Posts: n/a
 
      10-26-2004
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
 
Reply With Quote
 
 
 
 
Ken Dopierala Jr.
Guest
Posts: n/a
 
      10-27-2004
Hi Ed,

You can't do it that way. You need to create the type from the web service
itself:

Dim CurrentUser As New UsersWS.Common.User()
CurrentUser = UsersWS.GetUser()

That should make it work. Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"MisterEd" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
MisterEd
Guest
Posts: n/a
 
      10-27-2004
Thanks for the help!

The only problem is that I would like to use two member functions that I
have written for the User class. For some reason, whenever I call the
webservice, the UsersWS.User class does not have those functions.

Is there any way I can get it to convert back to that same base (I'm not
sure this is the proper term) class with the member functions?

Thanks again,
Ed

"Ken Dopierala Jr." wrote:

> Hi Ed,
>
> You can't do it that way. You need to create the type from the web service
> itself:
>
> Dim CurrentUser As New UsersWS.Common.User()
> CurrentUser = UsersWS.GetUser()
>
> That should make it work. Good luck! Ken.
>
> --
> Ken Dopierala Jr.
> For great ASP.Net web hosting try:
> http://www.webhost4life.com/default.asp?refid=Spinlight
> If you sign up under me and need help, email me.
>
> "MisterEd" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
Ken Dopierala Jr.
Guest
Posts: n/a
 
      10-28-2004
Hi Ed,

I don't believe you can serialize executable code through a web service. I
would create a business logic layer that accepts your class as a parameter
(make sure your business logic layer is using a class based on a type from
the web service and not from the Common.User class directly), then have this
layer consume the class you receive through the web service. Good luck!
Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"MisterEd" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks for the help!
>
> The only problem is that I would like to use two member functions that I
> have written for the User class. For some reason, whenever I call the
> webservice, the UsersWS.User class does not have those functions.
>
> Is there any way I can get it to convert back to that same base (I'm not
> sure this is the proper term) class with the member functions?
>
> Thanks again,
> Ed
>
> "Ken Dopierala Jr." wrote:
>
> > Hi Ed,
> >
> > You can't do it that way. You need to create the type from the web

service
> > itself:
> >
> > Dim CurrentUser As New UsersWS.Common.User()
> > CurrentUser = UsersWS.GetUser()
> >
> > That should make it work. Good luck! Ken.
> >
> > --
> > Ken Dopierala Jr.
> > For great ASP.Net web hosting try:
> > http://www.webhost4life.com/default.asp?refid=Spinlight
> > If you sign up under me and need help, email me.
> >
> > "MisterEd" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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

> >
> >
> >



 
Reply With Quote
 
MisterEd
Guest
Posts: n/a
 
      10-28-2004
That sounds like the way I am going to have to do it. Thanks again for the
help!

"Ken Dopierala Jr." wrote:

> Hi Ed,
>
> I don't believe you can serialize executable code through a web service. I
> would create a business logic layer that accepts your class as a parameter
> (make sure your business logic layer is using a class based on a type from
> the web service and not from the Common.User class directly), then have this
> layer consume the class you receive through the web service. Good luck!
> Ken.
>
> --
> Ken Dopierala Jr.
> For great ASP.Net web hosting try:
> http://www.webhost4life.com/default.asp?refid=Spinlight
> If you sign up under me and need help, email me.
>
> "MisterEd" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Thanks for the help!
> >
> > The only problem is that I would like to use two member functions that I
> > have written for the User class. For some reason, whenever I call the
> > webservice, the UsersWS.User class does not have those functions.
> >
> > Is there any way I can get it to convert back to that same base (I'm not
> > sure this is the proper term) class with the member functions?
> >
> > Thanks again,
> > Ed
> >
> > "Ken Dopierala Jr." wrote:
> >
> > > Hi Ed,
> > >
> > > You can't do it that way. You need to create the type from the web

> service
> > > itself:
> > >
> > > Dim CurrentUser As New UsersWS.Common.User()
> > > CurrentUser = UsersWS.GetUser()
> > >
> > > That should make it work. Good luck! Ken.
> > >
> > > --
> > > Ken Dopierala Jr.
> > > For great ASP.Net web hosting try:
> > > http://www.webhost4life.com/default.asp?refid=Spinlight
> > > If you sign up under me and need help, email me.
> > >
> > > "MisterEd" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > 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
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
Dino Chiesa [Microsoft]
Guest
Posts: n/a
 
      10-28-2004
you could of course, modify the generated proxy class to reference your own
type. This will work if you are sure that both your type and the generated
type serialize to the same XML.


"MisterEd" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> That sounds like the way I am going to have to do it. Thanks again for
> the
> help!
>
> "Ken Dopierala Jr." wrote:
>
>> Hi Ed,
>>
>> I don't believe you can serialize executable code through a web service.
>> I
>> would create a business logic layer that accepts your class as a
>> parameter
>> (make sure your business logic layer is using a class based on a type
>> from
>> the web service and not from the Common.User class directly), then have
>> this
>> layer consume the class you receive through the web service. Good luck!
>> Ken.
>>
>> --
>> Ken Dopierala Jr.
>> For great ASP.Net web hosting try:
>> http://www.webhost4life.com/default.asp?refid=Spinlight
>> If you sign up under me and need help, email me.
>>
>> "MisterEd" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > Thanks for the help!
>> >
>> > The only problem is that I would like to use two member functions that
>> > I
>> > have written for the User class. For some reason, whenever I call the
>> > webservice, the UsersWS.User class does not have those functions.
>> >
>> > Is there any way I can get it to convert back to that same base (I'm
>> > not
>> > sure this is the proper term) class with the member functions?
>> >
>> > Thanks again,
>> > Ed
>> >
>> > "Ken Dopierala Jr." wrote:
>> >
>> > > Hi Ed,
>> > >
>> > > You can't do it that way. You need to create the type from the web

>> service
>> > > itself:
>> > >
>> > > Dim CurrentUser As New UsersWS.Common.User()
>> > > CurrentUser = UsersWS.GetUser()
>> > >
>> > > That should make it work. Good luck! Ken.
>> > >
>> > > --
>> > > Ken Dopierala Jr.
>> > > For great ASP.Net web hosting try:
>> > > http://www.webhost4life.com/default.asp?refid=Spinlight
>> > > If you sign up under me and need help, email me.
>> > >
>> > > "MisterEd" <(E-Mail Removed)> wrote in message
>> > > news:(E-Mail Removed)...
>> > > > 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
>> > >
>> > >
>> > >

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Call CFUNCTYPE, class Structure, ctype, dll and Callback functionproblem legard_new Python 2 08-01-2010 06:42 AM
ctype and functions that return a pointer to a structure hg Python 2 07-01-2007 09:53 PM
JNI does not return the original value Neena Java 2 09-28-2005 08:49 AM
Return user to original view =?Utf-8?B?U2FuZHk=?= ASP .Net 3 04-21-2005 12:31 AM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM



Advertisments