returning object from wcf service

A

Andrus

wcf web service returns List<PickListEntity> where PickListEntity is
defined as:

[DataContract]
public sealed class PickListEntity
{
[DataMember]
public string DisplayMember { get; set; }

[DataMember]
public object ValueMember { get; set; }
}

ValueMember can be string, int or decimal depending on passed parameters

Calling this returns strange error about cannot deserialize
MultiCastDeletage when result is retrieved.
Calling same method of ASMX web service works OK.

How to return List<PickListEntity> from WCF web servie ?

Andrus.
 
M

Mr. Arnold

Andrus said:
wcf web service returns List<PickListEntity> where PickListEntity is
defined as:

[DataContract]
public sealed class PickListEntity
{
[DataMember]
public string DisplayMember { get; set; }

[DataMember]
public object ValueMember { get; set; }
}

ValueMember can be string, int or decimal depending on passed parameters

Calling this returns strange error about cannot deserialize
MultiCastDeletage when result is retrieved.
Calling same method of ASMX web service works OK.

How to return List<PickListEntity> from WCF web servie ?

Andrus.

You can't return 'Object' as it's not serializable with WCF. If objects are
going to be retuned, then they must be custom serialized objects that are
decorated with the [Serializable] attribute.

Of course BrokenRule is another class/object that's decorated with the
[Serializable] attribute returned within the already serialized
class/object. Shippers in the example.
[Serializable]

[DataContractAttribute(IsReference=true)]

public class Shippers

{

private List<BrokenRule> _brokenrules = new List<BrokenRule>();

[DataMemberAttribute]

public List<BrokenRule> BrokenRules

{

get { return _brokenrules; }

set { _brokenrules = value; }

}

[DataMemberAttribute]

public Int32 ShipperID {get; set;}

[DataMemberAttribute]

public string CompanyName {get; set;}

[DataMemberAttribute]

public string Phone {get; set;}

}


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4518 (20091017) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
A

Andrus

You can't return 'Object' as it's not serializable with WCF. If objects
are going to be retuned, then they must be custom serialized objects that
are decorated with the [Serializable] attribute.

Using ASMX web service we can define object as return type and assing
string, int or decimalt to it in service.
On client side string,int or decimal object is automatically deserialized.

How to obtain same functionality in WCF ?

Andrus.
 
M

Mr. Arnold

Andrus said:
You can't return 'Object' as it's not serializable with WCF. If objects
are going to be retuned, then they must be custom serialized objects
that are decorated with the [Serializable] attribute.

Using ASMX web service we can define object as return type and assing
string, int or decimalt to it in service.

An ASP.NET legacy Web service is not an ASP.NET WCF Web service, which are
playing with two different set of rules.
On client side string,int or decimal object is automatically deserialized.

How to obtain same functionality in WCF ?

You cannot pass an object that WCF can't serialize. It's a simple as that.
(Object) can't be serialized due to the way you're using it.

Now, you can set Object to a serialized object and pass it as Object
because Object is pointing to a class/object that can be serialized.

http://www.danrigsby.com/blog/index...-datacontractserializer-serialization-in-wcf/


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4520 (20091018) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
M

Mr. Arnold

Andrus said:
You can't return 'Object' as it's not serializable with WCF. If objects
are going to be retuned, then they must be custom serialized objects
that are decorated with the [Serializable] attribute.

Using ASMX web service we can define object as return type and assing
string, int or decimalt to it in service.
On client side string,int or decimal object is automatically deserialized.

How to obtain same functionality in WCF ?


And the way the class is decoreted without the [Seralizable] attribute,
you're not going to be able to return it, not in an ASP.NET WCF Web
service.

[DataContract]
public sealed class PickListEntity
{
[DataMember]
public string DisplayMember { get; set; }

[DataMember]
public object ValueMember { get; set; }
}


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4520 (20091018) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 
V

vinayaga moorthi A

hai

now i'm also working in wcf. i'm new to wcf.please reffer to me any website to return as object




Mr. Arnold wrote:

You cannot return 'Object' as it is not serializable with WCF.
17-Oct-09

You cannot return 'Object' as it is not serializable with WCF. If objects ar
going to be retuned, then they must be custom serialized objects that ar
decorated with the [Serializable] attribute

Of course BrokenRule is another class/object that is decorated with th
[Serializable] attribute returned within the already serialize
class/object. Shippers in the example
[Serializable

[DataContractAttribute(IsReference=true)

public class Shipper



private List<BrokenRule> _brokenrules = new List<BrokenRule>()

[DataMemberAttribute

public List<BrokenRule> BrokenRule



get { return _brokenrules;

set { _brokenrules = value;



[DataMemberAttribute

public Int32 ShipperID {get; set;

[DataMemberAttribute

public string CompanyName {get; set;

[DataMemberAttribute

public string Phone {get; set;



__________ Information from ESET NOD32 Antivirus, version of virus signature database 4518 (20091017) _________

The message was checked by ESET NOD32 Antivirus

http://www.eset.com

Previous Posts In This Thread:

returning object from wcf service
wcf web service returns List<PickListEntity> where PickListEntity i
defined as

[DataContract
public sealed class PickListEntit

[DataMember
public string DisplayMember { get; set;

[DataMember
public object ValueMember { get; set;


ValueMember can be string, int or decimal depending on passed parameter

Calling this returns strange error about cannot deserializ
MultiCastDeletage when result is retrieved
Calling same method of ASMX web service works OK

How to return List<PickListEntity> from WCF web servie

Andrus.

You cannot return 'Object' as it is not serializable with WCF.
You cannot return 'Object' as it is not serializable with WCF. If objects ar
going to be retuned, then they must be custom serialized objects that ar
decorated with the [Serializable] attribute

Of course BrokenRule is another class/object that is decorated with th
[Serializable] attribute returned within the already serialize
class/object. Shippers in the example
[Serializable

[DataContractAttribute(IsReference=true)

public class Shipper



private List<BrokenRule> _brokenrules = new List<BrokenRule>()

[DataMemberAttribute

public List<BrokenRule> BrokenRule



get { return _brokenrules;

set { _brokenrules = value;



[DataMemberAttribute

public Int32 ShipperID {get; set;

[DataMemberAttribute

public string CompanyName {get; set;

[DataMemberAttribute

public string Phone {get; set;



__________ Information from ESET NOD32 Antivirus, version of virus signature database 4518 (20091017) _________

The message was checked by ESET NOD32 Antivirus

http://www.eset.com

Using ASMX web service we can define object as return type and assingstring,
Using ASMX web service we can define object as return type and assin
string, int or decimalt to it in service
On client side string,int or decimal object is automatically deserialized

How to obtain same functionality in WCF

Andrus.

An ASP.NET legacy Web service is not an ASP.
An ASP.NET legacy Web service is not an ASP.NET WCF Web service, which ar
playing with two different set of rules

You cannot pass an object that WCF cannot serialize. it is a simple as that
(Object) cannot be serialized due to the way you are using it

Now, you can set Object to a serialized object and pass it as Objec
because Object is pointing to a class/object that can be serialized

http://www.danrigsby.com/blog/index...s-datacontractserializer-serialization-in-wcf

__________ Information from ESET NOD32 Antivirus, version of virus signature database 4520 (20091018) _________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com

And the way the class is decoreted without the [Seralizable] attribute,you are
And the way the class is decoreted without the [Seralizable] attribute,
you are not going to be able to return it, not in an ASP.NET WCF Web
service.

[DataContract]
public sealed class PickListEntity
{
[DataMember]
public string DisplayMember { get; set; }

[DataMember]
public object ValueMember { get; set; }
}


__________ Information from ESET NOD32 Antivirus, version of virus signature database 4520 (20091018) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com


Submitted via EggHeadCafe - Software Developer Portal of Choice
Server Side Processing in ADO.NET/WCF Data Services
http://www.eggheadcafe.com/tutorial...f-4f6f92a76585/server-side-processing-in.aspx
 
M

Mr. Arnold

vinayaga said:
hai

now i'm also working in wcf. i'm new to wcf.please reffer to me any website to return as object


<http://www.google.com/#hl=en&q=wcf+...cf+datacontract+&gs_rfai=&fp=d90e7c340cb31971>


Where I really learned how to create the WCF custom object is I looked
at the ADO.NET Entity Framework for a given table that was defined as
an implicit WCF DataContract object/entity when generated, meaning you
can send that object to/from the client through WCF as is and nothing on
your part has to be done. The EF entity is an implicit WCF DataContract.

You'll see the usage of the attributes talked about above if you look at
a generated object/class in the designer of EF for a given entity. You
do that then you'll see how the attributes are used in WCF custom object
creation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top