JsonResult因安全连接而变得混乱

时间:2012-01-30 21:44:25

标签: android asp.net-mvc web-services ssl https

我正在尝试构建一个Web服务,以便与需要安全连接的移动应用程序进行交互。

在不安全的连接上,我从服务器获得所需的JSON结果,并且可以构建适当的JSON对象(在测试设备上)。

所需的JSON结果是:

{"memberID":"999999","statusCode":"0","message":"Your member information has been processed, please confirm to continue with payment.","total":"66.66"}

但是,使用安全连接,控制器返回:

ur member information has been processed, please confirm to continue with payment.","total":"66.66"}

服务器端代码现在很简单:

[HttpPost]
public JsonResult startTransaction( FormCollection form ) {
    // process form values
    Dictionary<string,string> result = new dictionary<string,string>();
    result.Add("memberID","999999");
    result.Add("statucCode","0");
    result.Add("message","Your member information has been processed, please confirm to continue with payment.");
    result.Add("total","66.66");

    return Json(result);
}

如果在开发方面,在设备端(Android)有帮助,我接受https的所有证书。

我不确定如何以这种方式缩短响应。

更新

在尝试Fiddler2,Firebug和JSONView之后,我似乎无法解决错误。

读取响应的代码(在Android设备上)是:

responseStream = connection.getInputStream();
int bytesRead = -1;
byte[] buffer = new byte[8*1024];

while( (bytesRead = responseStream.read(buffer)) >= 0 ) {}

response = new String( buffer );

我认为缓冲区太小了,但事实并非如此,因为我尝试了更大的缓冲区大小。

1 个答案:

答案 0 :(得分:1)

我会尝试Fiddler或Firebug来执行HTTPS请求并查看结果。通过这种方式,您可以了解问题是在服务器上还是在客户端上。