2012-12-21 30 views
2

我想getSessionID與eBay API的代碼像XML解析器這個錯誤輸入傳輸已經終止,因爲您的請求超時

static final String url = "https://api.sandbox.ebay.com/ws/api.dll"; 

代碼;

DefaultHttpClient httpClient = new DefaultHttpClient(); 
       HttpPost httpPost = new HttpPost(url); 
       StringEntity se = new StringEntity("<RuName>\"my runame" /RuName>",HTTP.UTF_8); 
       se.setContentType("text/xml"); 
       httpPost.setHeader("X-EBAY-API-COMPATIBILITY-LEVEL","673"); 
       httpPost.setHeader("X-EBAY-API-APP-NAME", Constants.EBAY_APP_ID); 
       httpPost.setHeader("X-EBAY-API-DEV-NAME",Constants.EBAY_DEV_ID); 
       httpPost.setHeader("X-EBAY-API-CERT-NAME", Constants.EBAY_CERT_ID); 
       httpPost.setHeader("X-EBAY-API-SITEID","0"); 
       httpPost.setHeader("X-EBAY-API-CALL-NAME","GetSessionID"); 
       httpPost.setHeader("Content-Type","text/xml"); 

       HttpResponse httpResponse = httpClient.execute(httpPost); 
       HttpEntity httpEntity = httpResponse.getEntity(); 
       xml = EntityUtils.toString(httpEntity); 
       Log.e("xml", xml); 

但它表明這樣

12-21 11:26:12.878: ERROR/xml(643): <GetSessionIDResponse xmlns="urn:ebay:apis:eBLBaseComponents"><Timestamp>2012-12-21T04:26:13.673Z</Timestamp><Ack>Failure</Ack><Errors><ShortMessage>Input transfer has been terminated because your request timed out.</ShortMessage><LongMessage>Input transfer has been terminated because your request timed out.</LongMessage><ErrorCode>21359</ErrorCode><SeverityCode>Error</SeverityCode><ErrorParameters ParamID="0"><Value>Please try again.</Value></ErrorParameters><ErrorClassification>SystemError</ErrorClassification></Errors><Version>803</Version><Build>E803_CORE_BUNDLED_15615944_R1</Build></GetSessionIDResponse> 

任何解決方案應對錯誤,請?

回答

0

而不是使用DefaultHttpClient使用HttpClient
如下所示

HttpClient httpClient = new DefaultHttpClient(); 
final HttpParams httpParams = httpClient.getParams(); 
HttpConnectionParams.setConnectionTimeout(httpParams, 50000); 

方法setConnectionTimeout(int timeInMilliSeconds)將超時設置爲50秒。

+0

仍然顯示相同的錯誤:( – user1920582

+0

增加50000到70000,並嘗試:) – Pratik

+0

它解決了,因爲我忘了添加httpPost.setEntity(se); 。但是,當我添加這個顯示新的錯誤響應「<![CDATA [應用程序的內部錯誤]]>」,你有解決這個問題嗎? – user1920582

相關問題