-2

I am making a SOAP request to a web method using HTTP Post. The request and response are both JSON.

But while making the POST request i am getting an error :

The server cannot service the request because the media type is unsupported.

This is my code

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);

I have tried giving Accept-Encoding as application/json , text. But i still get the same error.

4

1 回答 1

0

SOAP 是一种基于 XML 的协议。请参阅https://en.wikipedia.org/wiki/SOAP和 W3C SOAP Primer

如果您想使用 JSON 进行通信,那很好 - 但它不是 SOAP。

于 2013-07-02T11:04:40.403 回答