0

我正在调用 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);

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

4

0 回答 0