-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.

ankit_rck
  • 1,796
  • 2
  • 14
  • 24

1 Answers1

0

SOAP is an XML-based protocol. See https://en.wikipedia.org/wiki/SOAP and the W3C SOAP Primer.

If you want to communicate using JSON, that's fine - but it isn't SOAP.

DNA
  • 42,007
  • 12
  • 107
  • 146