0
我需要從android發佈大JSON字符串到web服務使用澤西客戶端。以下代碼失敗,HTTP狀態爲505錯誤。看起來像JSON字符串的長度造成了麻煩,因爲當JSON字符串的長度不是太高時(我用200個字符長度測試),調用工作正常。我也懷疑這與android上的澤西庫有關,因爲與在eclipse中運行的澤西客戶端相同的確切代碼工作正常。在eclipse中,我甚至不需要在請求中設置壓縮標題。有人有什麼線索我在這裏錯過了什麼?張貼大JSON字符串與澤西客戶端上android
formData.add("payload",payload);
config = new DefaultClientConfig(); // SSL configuration
config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
new HTTPSProperties(JerseyClientBKS.getHostnameVerifier(), JerseyClientBKS.getSSLContext(getApplicationContext())));
ServiceFinder.setIteratorProvider(new AndroidServiceIteratorProvider());
client = Client.create(config);
webResource = client.resource(getSeletctedAddress()+"/api/document/submitHybridJSON");
builder = webResource.queryParams(formData).getRequestBuilder();
for (NewCookie c : getCookies()) {
if (c.getValue().indexOf("_") != -1){
builder = builder.cookie(c);
}
}
builder = builder.header("Content-Encoding", "gzip");
builder = builder.header("Accept-Encoding", "gzip");
Log.d(TAG, "posting.... = ");
response =builder.type(MediaType.APPLICATION_FORM_URLENCODED).post(ClientResponse.class);
Log.d(TAG,"response code "+response.getStatus());
Log.d(TAG,"valuesets "+response.getEntity(String.class));
5xx錯誤應該在服務器的錯誤日誌中有關於它們的詳細信息。看那裏尋找線索。 –
@MarcB我使用jboss,我在server.log中看不到任何東西,就好像服務器沒有收到請求。你知道我還能在哪裏找到有關錯誤的信息嗎?正如我所說的,它必須與JSON字符串的長度有關。 –
200字節不算什麼,即使是200 kB應該也沒有問題。嘗試使用「gzip」刪除標題。我認爲設定它們不是你的工作,如果適當的話,這應該是新澤西州。 – hgoebl