1

403-unauthorized などの例外を指定するために、ksoap 応答から http ステータス コードを取得する必要があります (認証にクライアント証明書を使用します - 証明書が無効な場合)。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();
}
...

ありがとう。

4

2 に答える 2

0
    URL myurl = new URL(url);
    URLConnection connection = myurl.openConnection();
    connection.setConnectTimeout(20 * 1000);
    HttpURLConnection httpConnection = (HttpURLConnection) connection;
    int responseCode = -1;

    if (responseCode == HttpURLConnection.HTTP_OK)
    {
        httpConnection.disconnect();
        SoapObject request = new SoapObject(namespace, methodName);
        //...
    }
    else if(...)
    {
        //...
    }
于 2012-05-14T12:09:11.073 に答える