将基于 ajax、jquery 的网络服务与 android 集成

Integrating ajax, jquery based webservices with android

我正在尝试使用当前在 ajax 中创建的网络服务。除了使用 POST 数据外,我不知道该 Web 服务实际上在做什么。当我尝试在 POSTMAN(Rest api 客户端)上查看其输出时,出现错误。

这是网络服务的结构:

var request = {};
request.UserName = "some data"; // this should be always hard coded like this 
request.Password = "some data";  // this should be always hard coded like this
request.CurrentUsername = "admin"; //   this is hard coded like this for now 

request.FirstName = "some data";
request.LastName = "some data";

var send = {};
send.request = request;
$.ajax({
    type: "POST",
    contentType: "application/json; charset=utf-8",
    url: "some link",
    data: JSON.stringify(send),
    dataType: "json",
    async: false,
    success: function (msg) {
        // Process the result here
    },
    error: function () {
        //alert("error");
        // Display the error here in the front end
    }
});
});
});

我需要在 android 中获取它的输出。由于我对 ajax、jquery(后端)知之甚少,并使用 Web 服务 link 通过 post 方法完成了 json 解析(在 android 中) ] 和参数。请指导我如何在这种情况下实施。

此外,我通常在 postman 上检查 Web 服务输出,但在这里它每次都给我错误的请求。

请帮忙。

您尝试过使用 Telerik 的 Fiddler4 吗?我在工作中苦苦挣扎了 2 周,做了一些与此非常相似的事情。我正在使用 webclient 将数据从 Android 发送到我的网页。我不停地出错。在线没有任何帮助。使用提琴手我能够看到我的 post 数据是什么,它在哪里以及所有细节。它应该可以帮助您缩小很多范围。

是的,终于找到了移动它的方法。非常简单,在 android 中需要遵循 header end that's all

httpPost.setHeader("Content-Type", "application/json");