From my Main question at Consuming web service with RESTKIT, I’ve learned some stuff, and came across many more obstacle in learning how to use RestKit.
One of the obstacle now is making my asmx file return the data in JSON. (Following a few method from http://williamsportwebdeveloper.com/cgi/wp/?p=494)
[WebMethod]
[ScriptMethod( ResponseFormat = ResponseFormat.Json)]
public string testText()
{
string name = "Herro World";
// return name;
JavaScriptSerializer js = new JavaScriptSerializer();
string strJSON = js.Serialize(name);
return strJSON;
}
However, the return when I invoke in browser is still <string xmlns="http://tempuri.org/">"Herro World"</string>
I am currently using .net 4.0. I tried reading up on diff article and SO thread, and tried to adapt their setting, but to no avail.
After looking closely at the example given in
http://williamsportwebdeveloper.com/cgi/wp/?p=494and reading up some information and articles, it turns out that we have to parse object. Meaning string could not be parse. The problem is solved by adding in an object to store the string.and this will return
<string xmlns="http://tempuri.org/">["Testing for Json!"]</string>Hope it help any new comer like me, who are trying to change the return format.