java - Jersey: Reading Content-Type:plain/text response as XML -


i'm receiving http response external server contains xml in body.

however, response header says content-type:plain/text

this incorrect , should application/xml. but, said, it's external server cannot change.

the following code gives error:

clientresponse response = client.create().resource(url).get(clientresponse.class); return response.getentity(xmlresponse.class); 

exception:

com.sun.jersey.api.client.clienthandlerexception: message body reader java class com.evs.ats.xmlresponse, , java type class com.evs.ats.xmlresponse, , mime media type text/plain not found

the following code works don't it:

string resultstring = response.getentity(string.class); inputstream stream = new bytearrayinputstream(     resultstring.getbytes(standardcharsets.utf_8) ); jaxbcontext jc = jaxbcontext.newinstance(xmlresponse.class); unmarshaller unmarshaller = jc.createunmarshaller(); return (xmlresponse) unmarshaller.unmarshal(stream); 

is there way "force" jersey read xml anyway? or option unmarshal manually using jaxb (like above)? or there option?


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -