我需要从 ksoap 响应中获取 http 状态代码以指定 403-unauthorized 等异常(我使用客户端证书进行身份验证 - 当证书无效时)。我试图在 ResponseProperties 中找到一个 http 状态(我认为应该在哪里),但我没有。
代码:
...
HttpsTransportSE transport=new HttpsTransportSE(host, port, service, timeout);
try {
SoapObject request=new SoapObject(namespace, method);
request.addProperty("param", param);
SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet=true;
envelope.setOutputSoapObject(request);
transport.call(getStatusAction, envelope);
SoapPrimitive response=(SoapPrimitive)envelope.getResponse();
nRet=Integer.parseInt(response.toString());
}
catch(Exception e) {
// Here I can get HeaderProperties by transport.getConnection().getResponseProperties();
// But http status code is not present
e.printStackTrace();
}
...
谢谢。