HighTechTalks DotNet Forums  

Getting unable to cast error (when same object is referenced in client and web service)

ASP.net Web Services microsoft.public.dotnet.framework.aspnet.webservices


Discuss Getting unable to cast error (when same object is referenced in client and web service) in the ASP.net Web Services forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Rahul
 
Posts: n/a

Default Getting unable to cast error (when same object is referenced in client and web service) - 01-14-2008 , 10:01 AM






I am getting following error:

1) For a xml file "Request.xml" we created a schema "Request.xsd".

2) With the help of xsd.exe we got the C# file Request.cs.

3) We tried to send the object of Request.cs to a webservice method
SaveRequest(Request req).

4) Scenario is like same Request.cs is referenced by both server and
client.

5)When we are trying to pass the req object of type Request we are getting
unable to cast error.

Is this expected? If so, are there any workarounds?


Please help us in solving this.

Thanks !!!!!




Reply With Quote
  #2  
Old   
John Saunders [MVP]
 
Posts: n/a

Default Re: Getting unable to cast error (when same object is referenced in client and web service) - 01-14-2008 , 11:33 AM






"Rahul" <rahuls (AT) rediff (DOT) com> wrote

Quote:
I am getting following error:

1) For a xml file "Request.xml" we created a schema "Request.xsd".

2) With the help of xsd.exe we got the C# file Request.cs.

3) We tried to send the object of Request.cs to a webservice method
SaveRequest(Request req).

4) Scenario is like same Request.cs is referenced by both server and
client.

5)When we are trying to pass the req object of type Request we are getting
unable to cast error.

Is this expected? If so, are there any workarounds?
This is expected. The classes on the client side are proxy classes only -
they are not meant to be the same as the server-side classes. Their only
purpose is to make it easier for you to call the web methods exposed by the
server.

In fact, if you ever get a situation with ASMX web services where you have
the same class on the client and the server, then you've almost certainly
made a very serious mistake.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer




Reply With Quote
  #3  
Old   
John Saunders [MVP]
 
Posts: n/a

Default Re: Getting unable to cast error (when same object is referenced in client and web service) - 01-14-2008 , 11:33 AM



"Rahul" <rahuls (AT) rediff (DOT) com> wrote

Quote:
I am getting following error:

1) For a xml file "Request.xml" we created a schema "Request.xsd".

2) With the help of xsd.exe we got the C# file Request.cs.

3) We tried to send the object of Request.cs to a webservice method
SaveRequest(Request req).

4) Scenario is like same Request.cs is referenced by both server and
client.

5)When we are trying to pass the req object of type Request we are getting
unable to cast error.

Is this expected? If so, are there any workarounds?
This is expected. The classes on the client side are proxy classes only -
they are not meant to be the same as the server-side classes. Their only
purpose is to make it easier for you to call the web methods exposed by the
server.

In fact, if you ever get a situation with ASMX web services where you have
the same class on the client and the server, then you've almost certainly
made a very serious mistake.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer




Reply With Quote
  #4  
Old   
John Saunders [MVP]
 
Posts: n/a

Default Re: Getting unable to cast error (when same object is referenced in client and web service) - 01-14-2008 , 11:33 AM



"Rahul" <rahuls (AT) rediff (DOT) com> wrote

Quote:
I am getting following error:

1) For a xml file "Request.xml" we created a schema "Request.xsd".

2) With the help of xsd.exe we got the C# file Request.cs.

3) We tried to send the object of Request.cs to a webservice method
SaveRequest(Request req).

4) Scenario is like same Request.cs is referenced by both server and
client.

5)When we are trying to pass the req object of type Request we are getting
unable to cast error.

Is this expected? If so, are there any workarounds?
This is expected. The classes on the client side are proxy classes only -
they are not meant to be the same as the server-side classes. Their only
purpose is to make it easier for you to call the web methods exposed by the
server.

In fact, if you ever get a situation with ASMX web services where you have
the same class on the client and the server, then you've almost certainly
made a very serious mistake.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer




Reply With Quote
  #5  
Old   
william
 
Posts: n/a

Default Re: Getting unable to cast error (when same object is referenced i - 02-27-2008 , 12:23 PM



Hi John,
I've went through similar steps as Rahul, which is that I created a class by
using xsd.exe, I have a web service which return this serialized class. I
declared a variable as this class, and assign the return value of my web
service to the variable, I got compiling error "Cannot implicitly convert
type MyWebServiceTest.MyService.GetUserInfoResponseGetU serInfoResult to
User".

How can I get result from my web service?

Thanks.

William

"John Saunders [MVP]" wrote:

Quote:
"Rahul" <rahuls (AT) rediff (DOT) com> wrote in message
news:uiWE9asVIHA.4740 (AT) TK2MSFTNGP02 (DOT) phx.gbl...
I am getting following error:

1) For a xml file "Request.xml" we created a schema "Request.xsd".

2) With the help of xsd.exe we got the C# file Request.cs.

3) We tried to send the object of Request.cs to a webservice method
SaveRequest(Request req).

4) Scenario is like same Request.cs is referenced by both server and
client.

5)When we are trying to pass the req object of type Request we are getting
unable to cast error.

Is this expected? If so, are there any workarounds?

This is expected. The classes on the client side are proxy classes only -
they are not meant to be the same as the server-side classes. Their only
purpose is to make it easier for you to call the web methods exposed by the
server.

In fact, if you ever get a situation with ASMX web services where you have
the same class on the client and the server, then you've almost certainly
made a very serious mistake.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer




Reply With Quote
  #6  
Old   
william
 
Posts: n/a

Default Re: Getting unable to cast error (when same object is referenced i - 02-27-2008 , 12:23 PM



Hi John,
I've went through similar steps as Rahul, which is that I created a class by
using xsd.exe, I have a web service which return this serialized class. I
declared a variable as this class, and assign the return value of my web
service to the variable, I got compiling error "Cannot implicitly convert
type MyWebServiceTest.MyService.GetUserInfoResponseGetU serInfoResult to
User".

How can I get result from my web service?

Thanks.

William

"John Saunders [MVP]" wrote:

Quote:
"Rahul" <rahuls (AT) rediff (DOT) com> wrote in message
news:uiWE9asVIHA.4740 (AT) TK2MSFTNGP02 (DOT) phx.gbl...
I am getting following error:

1) For a xml file "Request.xml" we created a schema "Request.xsd".

2) With the help of xsd.exe we got the C# file Request.cs.

3) We tried to send the object of Request.cs to a webservice method
SaveRequest(Request req).

4) Scenario is like same Request.cs is referenced by both server and
client.

5)When we are trying to pass the req object of type Request we are getting
unable to cast error.

Is this expected? If so, are there any workarounds?

This is expected. The classes on the client side are proxy classes only -
they are not meant to be the same as the server-side classes. Their only
purpose is to make it easier for you to call the web methods exposed by the
server.

In fact, if you ever get a situation with ASMX web services where you have
the same class on the client and the server, then you've almost certainly
made a very serious mistake.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer




Reply With Quote
  #7  
Old   
william
 
Posts: n/a

Default Re: Getting unable to cast error (when same object is referenced i - 02-27-2008 , 12:23 PM



Hi John,
I've went through similar steps as Rahul, which is that I created a class by
using xsd.exe, I have a web service which return this serialized class. I
declared a variable as this class, and assign the return value of my web
service to the variable, I got compiling error "Cannot implicitly convert
type MyWebServiceTest.MyService.GetUserInfoResponseGetU serInfoResult to
User".

How can I get result from my web service?

Thanks.

William

"John Saunders [MVP]" wrote:

Quote:
"Rahul" <rahuls (AT) rediff (DOT) com> wrote in message
news:uiWE9asVIHA.4740 (AT) TK2MSFTNGP02 (DOT) phx.gbl...
I am getting following error:

1) For a xml file "Request.xml" we created a schema "Request.xsd".

2) With the help of xsd.exe we got the C# file Request.cs.

3) We tried to send the object of Request.cs to a webservice method
SaveRequest(Request req).

4) Scenario is like same Request.cs is referenced by both server and
client.

5)When we are trying to pass the req object of type Request we are getting
unable to cast error.

Is this expected? If so, are there any workarounds?

This is expected. The classes on the client side are proxy classes only -
they are not meant to be the same as the server-side classes. Their only
purpose is to make it easier for you to call the web methods exposed by the
server.

In fact, if you ever get a situation with ASMX web services where you have
the same class on the client and the server, then you've almost certainly
made a very serious mistake.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer




Reply With Quote
  #8  
Old   
John Saunders [MVP]
 
Posts: n/a

Default Re: Getting unable to cast error (when same object is referenced i - 02-27-2008 , 06:11 PM



"william" <william (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi John,
I've went through similar steps as Rahul, which is that I created a class
by
using xsd.exe, I have a web service which return this serialized class. I
declared a variable as this class, and assign the return value of my web
service to the variable, I got compiling error "Cannot implicitly convert
type MyWebServiceTest.MyService.GetUserInfoResponseGetU serInfoResult to
User".

How can I get result from my web service?
William, that error message you posted seems to be cut off. Surely the
message doesn't end with the word "User".
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer




Reply With Quote
  #9  
Old   
John Saunders [MVP]
 
Posts: n/a

Default Re: Getting unable to cast error (when same object is referenced i - 02-27-2008 , 06:11 PM



"william" <william (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi John,
I've went through similar steps as Rahul, which is that I created a class
by
using xsd.exe, I have a web service which return this serialized class. I
declared a variable as this class, and assign the return value of my web
service to the variable, I got compiling error "Cannot implicitly convert
type MyWebServiceTest.MyService.GetUserInfoResponseGetU serInfoResult to
User".

How can I get result from my web service?
William, that error message you posted seems to be cut off. Surely the
message doesn't end with the word "User".
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer




Reply With Quote
  #10  
Old   
John Saunders [MVP]
 
Posts: n/a

Default Re: Getting unable to cast error (when same object is referenced i - 02-27-2008 , 06:11 PM



"william" <william (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi John,
I've went through similar steps as Rahul, which is that I created a class
by
using xsd.exe, I have a web service which return this serialized class. I
declared a variable as this class, and assign the return value of my web
service to the variable, I got compiling error "Cannot implicitly convert
type MyWebServiceTest.MyService.GetUserInfoResponseGetU serInfoResult to
User".

How can I get result from my web service?
William, that error message you posted seems to be cut off. Surely the
message doesn't end with the word "User".
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.