1. if WCF service is not working, . I have to tell the message "Service is not working "
エラーコードが404であるならば、あなたはサービスがダウンしているユーザーに伝えることができ、あなたのHTTPリクエストクラスは404エラーコードをチェックしていることを確認します。
2. Service is working fine, but accessing time is long then need to tell "Timeout to connect to service."
次の2つの方法でそれを行うことができ、まず、その要求をキャンセルしたときに、必要なタイムアウト後に実行し、タイムアウトエラーを表示するようにTimerTaskをまたは遅延ハンドラを持っています。もう1つは、setConnectionTimeout
()とsetSoTimeout()
を使用してリクエスト自体にタイムアウト値を設定し、ontimeoutがメッセージを表示するためにキャッチできるConnectTimeoutException
を発生させることです。
HttpParams httpParameters = new BasicHttpParams();
// Set the timeout in milliseconds until a connection is established.
int timeoutConnection = 20000;
HttpConnectionParams.setConnectionTimeout(httpParameters,
timeoutConnection);
// Set the default socket timeout (SO_TIMEOUT)
// in milliseconds which is the timeout for waiting for data.
int timeoutSocket = 60000;
HttpConnectionParams.setSoTimeout(httpParameters, timeoutSocket);
HttpClient client = new DefaultHttpClient(httpParameters);
ありがとうございます。 2番目のオプションは大丈夫です。最初のオプションでは、どのようにエラーコードを取得できますか?私はKsoapを使用しています。 SoapObjectリクエスト=新しいSoapObject(NAMESPACE、METHOD_NAME); SoapSerializationEnvelopeエンベロープ=新しいSoapSerializationEnvelope(SoapEnvelope.VER11);データを石鹸に入れる envelope.dotNet = true; envelope.setOutputSoapObject(request); AndroidHttpTransport httpTransport =新しいAndroidHttpTransport(URL); { httpTransport.call(SOAP_ACTION、envelop); 応答=(SoapPrimitive)envelope.getResponse(); } catch(例外e){} – Piraba