Pass the array list to the WCF application

后端 未结 2 1980
孤城傲影
孤城傲影 2021-01-24 07:37

I am new to WCF. I have a scenario where i have \"Error.

When i am trying to pass the arr

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-24 07:44

    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.

提交回复
热议问题