locked
WCF REST JSON Service consumed by IPad App RRS feed

  • Question

  • I have built a WCF REST JSON service (using C#) that is to be consumed by an IPad app.  I am new to REST and JSON but have read many articles and have a basic Hello World service that works using a browser.  The IPad app expects JSON and I am told expects UTF8 encoded strings instead of Unicode.  Before I found out the IPad app expects UTF8 encoded strings, the return type of my one method was a class that had a property with a name expected by the IPad app.  Now because I know the IPad app expects UTF8 encoded strings, I believe I am to use the UTF8Encoding class in the C# service code and return Byte[], for example: 

    string response = "{name:John}";
    UTF8Encoding utf8 = new UTF8Encoding();
    return utf8.GetBytes(response);

    Is this typical for an IPad client consuming a WCF REST service, for the service methods to return Byte[]?








    Monday, April 4, 2011 9:09 PM

Answers

  • Hello,

    Returning a byte array is not required, I recommand looking first at the WCF rest samples of Microsoft. You can construct an object model of datacontracts and let WCF serialize this in the required string of the required text encoding.

    http://msdn.microsoft.com/en-us/library/ee834510.aspx

    Regards,
    Pieter

    • Proposed as answer by Pieter De Rycke Thursday, April 7, 2011 3:23 PM
    • Marked as answer by Yi-Lun Luo Monday, April 11, 2011 9:01 AM
    Tuesday, April 5, 2011 9:26 AM