Question

I am trying to add a new service method to my existing WCF web service project which uses BasicHttpBinding.
My new service method accepts a class as a parameter and this class has a List<T> variable. After adding this method, my web service client can not add the service reference. It receives (415) Unsupported Media Type. error message.
Does that mean WCF BasicHttpBinding does not support List type? Should I use array type instead? If it supports List, then where should I look for the error?

Was it helpful?

Solution

List is supported.

Check the configuration on misspelling!

For example, NetworkingService instead of NetwokingService link.

When you adding the service reference check configuration window. There is a choice how to consider List, Dictionary, Array when data is send. Choose as List.

Do not try work with anonymous generic List<T>. WCF cannot create WSDL information for anonymous types. It may be List<MyClass>.

Also it is not recommended for using because of data ceiling. The maximum bytes value is configurable but is limited. The better solution is to implement new class

public class MyClassContainer
{
    public Guid Id;
    public List<MyClass> Items;
}

And then send or receive objects by parts (by 10, 100 ,...).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top