2013-07-02 147 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 –

回答