How to expose my collection from the Web Service (WCF)

I have a custom collection which i want to expose from the WCF web service.

[DataContract( Name = "MyClass")]
public class MyCollection : IDisposable, List<MyClass> 
{
}

When I use [DataContract( Name = “MyClass”)] attribute it gives error

Type MyCollection is an invalid collection type since it has DataContractAttribute attribute.

How to expose multiple MEX endpoints from a WCF service?

I have an existing web service and I want it to expose 2 MEX endpoints, one exposed through whatever binding it already has and one through Service Bus Relay Binding. I know how to expose a metadata e

Expose WCF Web service on the internet configuration

I am trying to expose a webservice written in WCF, to the open internet but i am having trouble configuring it to be consumed from the external url. The web service is hosted internally at https://our

Simplest way to expose my custom data from WCF Data Service?

I have some data in files (not database). What is the simplest way to expose it as a WCF Data Service?

To expose WCF service as asmx(web service) and hosted in window service

I am developing the wcf application in VS2008. I want to host that WCF service as window service. But I also want to expose that service as .asmx(web service). Is it possible to do? Is there any way

How to expose data in my WCF Service

This is somewhat of a silly question.But… I am exposing a service of Street locations. What I have been doing so far is getting my data using Entity Framework and parsing the data into XML using XEl

WCF OperationContract – which generic collection type should I expose?

I have a WCF web service that has a method that returns a generic collection. Now, my question is: Should I expose it as ICollection<T>, List<T>, IList<T>, IEnumerable<T> or so

How to access SQL Server from my WCF web service?

VS Express 2012, SQL Server Express 2012, Win 8.1 Hello, I have a (very) simple WCF hosted as a web service on IIS. I also have a SQL Server instance (with 1 table) installed on the same machine. I ne

Why my WCF service doesn’t expose metadata?

I’m fighting with a WCF service which doesn’ want to expose metadata. The configuration file, according to a lot of posts around internet, seems to be OK: <service behaviorConfiguration=Mia.Config

How do I expose a WCF web service call response header in C#

I am using Visual Studio 2008 and have added a web reference that points to a WCF web service. Visual Studio has generated a client class automatically, so all I need to do to call the web service is

WHY doesn’t WCF ‘properly’ consume/expose abstract types when hosted as a web service

I’ve been designing web services for quite a while now but never had to expose a ‘complicated’ WCF service until recently. I was baffled at the apparent lack of proper support in WCF for abstract ty

Answers

You’ll need to use the CollectionDataContract attribute to handle this in WCF.

[CollectionDataContract] 
public class MyCollection : IDisposable, List<MyClass> 
{
}

Marc