Adding Array of Datacontracts as part of Message Contract

Jul 28, 2009 at 7:48 PM

All,

I have a operation for which the response object ( i.e. Response Message Contract) should return a array of Data Contracts.

I dont see how can i do this because i can either add a primitive message part or data contract message part but not a array or collection of data contracts.

Thanks,

Naveen Kumar.

Jul 28, 2009 at 9:02 PM
naveen_virgo14 wrote:
>
> From: naveen_virgo14
>
> All,
>
> I have a operation for which the response object ( i.e. Response
> Message Contract) should return a array of Data Contracts.
>
> I dont see how can i do this because i can either add a primitive
> message part or data contract message part but not a array or
> collection of data contracts.
>
> Thanks,
>
> Naveen Kumar.
>

I'm not sure if this answers your question, but here goes.

If you have your data contract design surface open, you will find that
there is a Data Contract Enumeration available in the Toolbox. You can
drag this to the design surface and then use it as a return type (or
whatever) in your Service Contract.

Apologies if this was not what you were after.

Regards


Peter
Jul 29, 2009 at 2:38 PM

Peter,

I do know that i can create a Data Contract Collection and refer it in the message contract. But i need to create another datacontract in this case.

I was just curious to know whether there is a way to refer array of data contract directly in the Message contract.

Thanks,

Naveen Kumar.

Developer
Aug 2, 2009 at 3:36 PM

Hi Naveen,

As you pointed out, you can only refer to a DataContractCollection from your MessageContract. In this case perhaps you can have your collection defined like a List<T> where T is your DC element in your array. This way you will have only one level of indirection in your Service Contract so your Message Contract will define a DC Collection that derives from List<YourDataContract>.

That is the closest you can get from having an array in your Message Contract.