Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsupported content type: text/plain; charset=ISO-8859-1

I have a webservice which has to return player details in response. The problem is, when I send same request in SoapUI I get valid response, but when I do this through Java, I get back this message in

<faultstring> Unsupported content type: text/plain; charset=ISO-8859-1 </faultstring>.

Any ideas why it is the problem?

This is request I am sending:

> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:gen=" ">   
> <soapenv:Header/>   
> <soapenv:Body>
>       <gen:GetPlayerDetails>
>          <request>
>             <systemUID>C_GS01</systemUID>
>             <sessionID>TVM0MgAAB9IAAAFEjXyfxbvZ2oU_</sessionID>
>          </request>
>       </gen:GetPlayerDetails>    
> </soapenv:Body>
> </soapenv:Envelope>

SOLVED thanks to @helderdarocha Made some changes (last line) in my HTTP client class:

        HttpClient httpclient = HttpClientBuilder.create().build();
        StringEntity strEntity = new StringEntity(request);
        HttpPost post = new HttpPost("http://10.47.44.163:8080" + endPointURI);
        post.addHeader("Content-type", "text/xml");
like image 891
mrk2 Avatar asked Mar 04 '14 15:03

mrk2


1 Answers

You are probably sending a request without the appropriate headers. You have to declare the type of data your client accepts as a response using the Accept header:

Accept: application/xml; application/json;

Additionally, if you are sending data, you have to declare the Content-type of what you are sending, and it should be compatible with the data your service accepts.

Content-type: application/xml

If you are sending payload in XML, for example.

like image 120
helderdarocha Avatar answered Nov 04 '22 22:11

helderdarocha