在SOAP解析时获取socketTimeOut异常

时间:2013-10-29 13:00:21

标签: android android-ksoap2

我正在使用chartlyrics api来获取歌词文本。但有时它会很好,有时会给出socketTimeout exception。我正在使用以下代码

      try {


        String SOAP_NAMESPACE = "http://api.chartlyrics.com/";
        String SOAP_METHOD = "GetLyric";
        String SOAP_ACTION = SOAP_NAMESPACE + SOAP_METHOD;
        String url = "http://api.chartlyrics.com/apiv1.asmx?op=GetLyric";

        SoapObject requestCode = new SoapObject(SOAP_NAMESPACE, SOAP_METHOD);
        requestCode.addProperty("lyricId", Integer.valueOf(lyricsId));
        requestCode.addProperty("lyricCheckSum", lyricsCheckSum);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
        envelope.setOutputSoapObject(requestCode);
        envelope.dotNet = true;

//          AndroidHttpTransport androidHttpTransport = new AndroidHttpTransport(url);
        HttpTransportSE androidHttpTransport = new HttpTransportSE(url, 1000*60*5);

        androidHttpTransport.debug = true;
        androidHttpTransport.call(SOAP_ACTION, envelope);
        String responseDump = androidHttpTransport.responseDump;

        return responseDump;
    } catch (Exception e) {
        e.printStackTrace();
    }

我在这一行得到了这个例外

androidHttpTransport.call(SOAP_ACTION, envelope);

任何解决方案都会有很大的帮助。

0 个答案:

没有答案