我使用了此答案的代码Android services with RestFull web services
但是当我尝试这样打电话时,
json = restClientService.getResponseAsJSON("http://192.168.2.242/Test.aspx/Hello", params);
我的asp.net网页webmethod没有被解雇。我添加了Page_Load代码看起来很有效,但我希望能够调用WebMethods而不是页面本身。
public partial class Test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(new { Hi = "Mr" });
Response.End();
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public object Hello()
{
return new { Hi = "Mr" };
}
}