![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2yVH8jrOh3C1McKPOPYYtxroztgSBsKT_2pLC2kyxYZvkiSb8jAxAs3nm_wKcluQnYwENk4ho1ZRTDyeUz6ztpdVadaNP65Ja8Tzo2SI1gsIHN8n5aHIYao-vg-6YRV0jjfP6Sw/s320/XmlSource.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTsti2DEin4cWq-ElCMunbh2L9vfo3N0VL82oBzxe0U_FM27tFb4Nfo-udCUv924QtSrE20wAQFqHIZeQVUhNeLOQ1H4eg7ZRG-ECJvBOrsc9LwT1Myzw1tkzotf-_R7axADQBAA/s320/DataSet.png)
You then specify a nice request and response as with any message based WCF service:
namespace MyReports
{
[MessageContract(IsWrapped = true)]
public class DataRequest
{
[MessageBodyMember="A"]
private string _fieldA = string.Empty;
[MessageBodyMember="B"]
private string _fieldB = string.Empty;
[MessageBodyMember="C"]
private string _fieldC = string.Empty;
}
}
The response looks something like this:
namespace MyReports
{
[MessageContract]
public class DataReponse
{
[MessageBodyMember="Data"]
private data[] _data;
}
}
And the data object looks like this:
namespace MyReports
{
[DataContract]
public class Data
{
[DataMember(Name="First"]
private string _field1;
[DataMember(Name="Second"]
private string _field2;
[DataMember(Name="Third"]
private string _field3;
}
// Ctor, Getters and setters excluded
}
Voila you're done... Or are you?!?
I found quite a nasty gotcha in doing this. My request class was only being partially populated everytime I did a request. I checked the attributes on the service and classes, I used TCP Trace to make sure the values were actually crossing the wire (which they were), but still the request wasn't being populated properly.
I even asked my pal [insert favourite search engine here] but couldn't fnd anything on it. So I started playing around with the fields in the report and low 2 of the 6 request params were now being populated! What had changed? The ordering. After a few more trial and errors I found the problem. The parameters from the report have to be sent in alphabetic order, otherwise for some reason the request doesn't deserialise properly.
No comments:
Post a Comment