Forcing webservice class to be serializable
Messages   Related Types
This message was discovered on ASPFriends.com 'aspngwebservices' list.


Bruno Carlos
-- Moved from [aspngfreeforall] to [aspngwebservices] by Tim Musschoot <Click here to reveal e-mail address> --

Anyone knows how to force a webservice class to be serializable after
regenerating it from wsdl?

I have in the web service:
[Serializable] public class UserInfo
{
public string username;
public string password;
}

But after wsdl I get in the reference.cs:
public class UserInfo {
/// <remarks/>
public string username;
/// <remarks/>
public string password;
}

Bruno Carlos

Reply to this message...
 
    
ramesh seshadri

[Serializable] attribute has no effect in the Asp.Net based webservices
stack. This attribute is used by Remoting technology to serialize types.

ramesh

[Original message clipped]

------------------------------------------------------------
Work An Hour for kids, with Asha for Education.
http://www.workanhour.com

_________________________________________________________________
Send and receive Hotmail on your mobile device: http://mobile.msn.com

Reply to this message...
 
    
Bruno Carlos
I know, I know. But I want to use those classes on the client side and need
them to have the Serializable attribute because I need to throw them to the
ViewState.

Basicaly on the client side I'm doing:

webservice.UserInfo userinfo = new webservice.UserInfo();
ViewState["userinfo"] = userinfo;

But naturally it produces the error that the class is not marked as
Serializable.

Even if I extend the class with something like:

public class ClientSideUserInfo : webservice.UserInfo {};

and then cast it in my calls as in:
webservice.UserInfo userinfo = webservice.getUserInfo(); // function that
returns a webservice.UserInfo object
ViewState["userinfo"] = (ClientSideUserInfo)userinfo;

It will create a runtime error saying its an invalid cast.

Bruno Carlos

----- Original Message -----
From: "ramesh seshadri" <Click here to reveal e-mail address>
To: "aspngwebservices" <Click here to reveal e-mail address>
Sent: Tuesday, June 18, 2002 2:37 AM
Subject: [aspngwebservices] Re: Forcing webservice class to be serializable

[Original message clipped]

Reply to this message...
 
 




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com