2013-07-02 144 views
-3

我正在使用HTTP Post向Web方法發出SOAP請求。請求和響應都是JSON。使用JSON進行HTTP POST SOAP請求

但同時使POST請求我得到一個錯誤:因爲媒體類型是不支持

服務器無法處理請求。

這是我的代碼

String SOAP_ACTION = "Method name"; 
String URL = "service url"; 
HttpPost httpPost = null; 

httpPost = new HttpPost(URL); 
httpPost.addHeader("Accept-Encoding", "gzip,deflate"); 
httpPost.addHeader("Content-Type", "application/json; charset=UTF-8"); 
httpPost.addHeader("SOAPAction", SOAP_ACTION); 

HttpEntity postEntity = new StringEntity(requestContent); 
httpPost.setEntity(postEntity); 

我曾嘗試給接受編碼爲application/JSON,文本。但我仍然得到同樣的錯誤。

+2

'...它依賴XML信息集的消息格式...' - http://en.wikipedia.org/wiki/SOAP – Selvin

+0

http://www.codeproject.com/Articles/45275/創建-A-JSON-WebService的功能於ASP-NET-2-0-與-A-jQu –

回答