开发者

Pass the array list to the WCF application

I am new to WCF. I have a scenario where i have

Pass the array list to the WCF application

.

When i am trying to pass the array list it giving the error. Please, have the look to image.

ICommissionService Definition

[Gener开发者_如何学JAVAatedCode("System.ServiceModel", "4.0.0.0")]
[ServiceContract(ConfigurationName = "FPCommission.ICommissionService")]
public interface ICommissionService
{
   [OperationContract(Action = "http://tempuri.org/ICommissionService/GetCommisionResponse",
                      ReplyAction = "http://tempuri.org/ICommissionService/GetCommisionResponseResponse")]
   object[] GetCommisionResponse(object[] loc_);
}

I am still not get the solution.


When you generate the Service reference, you should set the CollectionType to System.Collections.Arraylist - if you use the UI it's in the Advanced section, if you use svcutil.exe it's the /ct switch

There's a lot more information in Collections in Data Contracts on MSDN


This line is the problem, from the service:

object[] GetCommisionResponse(object[] loc_);

What you've told WCF here is that you're going to be returning an array of Object. Because of that, the client expects to get back an array of Object. That of course is not what you're actually giving it.

Subclasses don't work the same way in WCF that they work elsewhere. You have to explicitly define in the service what you're returning, because the client has to know what to expect and create classes for.

So if you're actually returning an array of Flight, change it to this:

Flight[] GetCommisionResponse(object[] loc_);

But if you're returning something and some subclasses of itself, you'll have to use the KnownType attribute.

[KnownType(typeof(FlightSubClass))]
Flight[] GetCommisionResponse(object[] loc_);

You can do the same thing on the Interface using ServiceKnownType, and only have to do it once.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜