Following operation contract works fine.
[OperationContract]
public Dictionary<string, string> GetDictionary()
Note that I have only put operation contract not decoration which needed to work WCF with iPhone and Json.
But if we change this that operation contract to following...
[OperationContract]
public string GetDictionary()
After doing this I started getting follwoing error.
The OperationFormatter could not serialize any information from the Message because the Message is empty
I was wondering as it was issue with primitive type string! where it was working find with complex type. I searched a lot but did not get any solution for this. The service was retuning Serialized Json data; but not sure what was wrong there. I was searching for workaround to this but didn’t find any then I wrap that string into concert class and and return that class object, and you don’t believe it works fine! Error is gone I fixed The OperationFormatter could not serialize any information from the Message because the Message is empty error, wow!!!!!
I have modified operation and now it looks like following.
[DataContract]
public class Response
{
[DataMember]
public string Data { get; set; }
}
[OperationContract]
public Response GetDictionary()
{
return new Response() { Data = "success" };
}
It still open question why it was not working in only string, however it was working with Dictionary object and then with Abstract type! I assume that at the time of serializing request its not able to create object of string as its primitive type! Not sure its true but it works fine with wrapper.



0 comments:
Post a Comment