I have a WCFService that returns sundry types of Data in this kind of a way:
[DataContract( Name="Amazing", NameSpace="http://schemas.myorganisation.com/DataContract1")]
Public class AmazingDto
{
[DataMember( Order=0, IsRequired=true )]
public string Name { get; set; }
[DataMember( Order=0, IsRequired=true )]
public bool IsAmazing { get; set; }
}
And then
[DataContract ( Name="GetAmazingListResponse", NameSpace="http://schemas.myorganisation.com/DataContract1")]
Public class GetAmazingListResponseDto
{
[DataMember(Order=0, IsRequired-true, EmitDefaultValue=False)]
public ICollection<AmazingDto> AmazingList{ get; set; }
}
Also
[DataContract(Name = "Response", Namespace = "http://schemas.myorganisation.com/DataContract1")]
public class ResponseDto<TData> : BaseResponseDto
{
public ResponseDto();
[DataMember(Order = 0, IsRequired = true)]
public StatusDto Status { get; set; }
[DataMember(Order = 1, IsRequired = false, EmitDefaultValue = false)]
public TData Data { get; set; }
}
And then
public ResponseDto<GetAmazingListResponseDto> GetAmazingList()
{
var response = new ResponseDto<GetAmazingListDto>
{
Status = new StatusDto { StatusResult = StatusResultEnum.Success },
Data = new GetAmazingListResponseDto
{
AmazingList = new List<AmazingDto>
{
new AmazingDto { Name="Ponies", IsAmazing=true },
new AmazingDto { Name="Glenatron", IsAmazing=false }
}
}
};
return response;
}
Now when I make a call to that service using a tool like SoapUI I get exactly the response I might expect.
<GetAmazingListResult xmlns:a="http://schemas.myorganisation.com/DataContract1" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:Status>
<a:StatusResult>Success</a:StatusResult>
</a:Status>
<a:Data xmlns:b="http://schemas.myorganisation.com/DataContract1">
<b:AmazingList>
<b:Amazing>
<b:Name>Ponies</b:Name>
<b:IsAmazing>true</b:IsAmazing>
</b:Amazing>
<b:Amazing>
<b:Name>Glenatron</b:Name>
<b:IsAmazing>false</b:IsAmazing>
</b:Amazing>
</b:AmazingList>
</a:Data>
</GetAmazingListResult>
However, when I use Visual Studio 2010 to create a Service Reference and make a call like this:
var client= new FindoutAmazingnessServiceClient();
var response = client.GetAmazingList();
What I find is that response
only has two properties, Status
and ExtensionData
. I have seen this described in other SE questions but the answer was always that something was missing a DataContract or DataMember on the data contracts. I definitely have those, so something else must be happening so that VS.Net can't see my classes. I have tried referencing the DTO library that contains these files and trying to configure the reference to match types with that library, but it makes no difference.
Where am I going wrong?