0

ksoap2 を使用して Web サービスに接続する Android アプリがありますが、クライアントからエラーが発生することがあります。自分のデバイスで自分自身をテストしているとき、すべてが問題ないので、どこに問題があるのか​​ わかりません.

私はこれらの例外を受け取ります:

java.net.ConnectException: failed to connect to example.com/91.10.10.10 (port 443) after 1800000ms: isConnected failed: ECONNREFUSED (Connection refused)
java.net.ConnectException: failed to connect to example.com/91.10.10.10 (port 443) after 1800000ms: connect failed: ENETUNREACH (Network is unreachable)
java.net.SocketException: failed to connect to example.com/91.10.10.10 (port 443) after 1800000ms: isConnected failed: EHOSTUNREACH (No route to host)

また

java.net.SocketException: Socket is closed

また

javax.net.ssl.SSLException: SSL handshake aborted: ssl=0x5cb6d638: I/O error during system call, Connection timed out

この関数を使用して、Web サービス関数を呼び出します。

private SoapObject makeCallToWebService(String soapAction, String method, PropertyInfo[] properties, boolean runInBackground) {
    int retry = RETRY_COUNT;
    int count = 0;

    if (mShouldRetryWhenError == false) {
        retry = 1;
    }

    while (count < retry) {
        count++;

        SoapObject request = new SoapObject(NAMESPACE, method);

        if (properties != null) {
            for (PropertyInfo property : properties) {
                request.addProperty(property);
            }
        }

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(request);;

        HttpsTransportSE transport = new HttpsTransportSE(HOST, PORT, FILE, TIMEOUT);

        transport.debug = true;
        transport.setXmlVersionTag("<?xml version=\"1.0\" encoding=\"utf-8\"?>");

        try {
            transport.call(NAMESPACE + "#" +  soapAction, envelope);

            SoapObject res = (SoapObject)envelope.bodyIn;

            return res;
        } catch (SocketTimeoutException e) {
            if (count == retry) {
                if (!runInBackground) {
                    handleError(method);
                }
            }
        } catch (Exception e) {
            Log.e(TAG, e.toString());

            if (!runInBackground) {
                handleError(null);
            }

            return null;
        }
    }

    return null;
}
4

1 に答える 1