An AXIS2 webservice is deployed in IIS. Using wsdl I generated JAX-WS client. It works fine if I use as standalone i.e, with Oracle JDK.
I have to call the webservice from my application that is deployed in websphere 7. So, i included the jax-ws generated client (as jar) in my application. When the application makes the call to the webservice it fails with java.io.UnsupportedEncodingException: text/xml exception. Websphere 7 uses axis2 related jar files for jax-ws.
Exception details:
Caused by: javax.xml.stream.XMLStreamException: java.io.UnsupportedEncodingException: text/xml
at com.ibm.xml.xlxp2.api.stax.msg.StAXMessageProvider.throwXMLStreamException(StAXMessageProvider.java:67)
at com.ibm.xml.xlxp2.api.stax.XMLStreamReaderImpl.setDocumentEntity(XMLStreamReaderImpl.java:401)
at com.ibm.xml.xlxp2.api.stax.XMLInputFactoryImpl.setDocumentEntity(XMLInputFactoryImpl.java:1440)
at com.ibm.xml.xlxp2.api.stax.XMLInputFactoryImpl.createXMLStreamReader(XMLInputFactoryImpl.java:1455)
at com.ibm.xml.xlxp2.api.stax.XMLInputFactoryImpl.createXMLStreamReaderInternal(XMLInputFactoryImpl.java:1555)
at com.ibm.xml.xlxp2.api.stax.XMLInputFactoryImpl.createXMLStreamReader(XMLInputFactoryImpl.java:1626)
at org.apache.axiom.om.util.StAXUtils$14.run(StAXUtils.java:618)
at java.security.AccessController.doPrivileged(AccessController.java:251)
at org.apache.axiom.om.util.StAXUtils.createSecureXMLStreamReader(StAXUtils.java:614)
at org.apache.axis2.builder.SOAPBuilder.processDocument(SOAPBuilder.java:58)
at org.apache.axis2.transport.TransportUtils.createDocumentElement(TransportUtils.java:191)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:139)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:102)
at org.apache.axis2.transport.TransportUtils.createSOAPMessage(TransportUtils.java:66)
at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:353)
at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:416)
at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:228)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:163)
at org.apache.axis2.jaxws.core.controller.impl.AxisInvocationController.execute(AxisInvocationController.java:581)
... 41 more
Caused by: java.io.UnsupportedEncodingException: text/xml
at sun.nio.cs.StreamDecoder.forInputStreamReader(StreamDecoder.java:115)
at java.io.InputStreamReader.<init>(InputStreamReader.java:93)
at com.ibm.xml.xlxp2.api.util.encoding.ByteStreamDataSource.convertToCharacterStream(ByteStreamDataSource.java:278)
at com.ibm.xml.xlxp2.api.util.encoding.PlatformEncodingSupport.loadFromByteStream(PlatformEncodingSupport.java:48)
at com.ibm.xml.xlxp2.api.util.SimpleParsedEntityFactory.detectEncodingSetSource(SimpleParsedEntityFactory.java:503)
at com.ibm.xml.xlxp2.api.util.SimpleParsedEntityFactory.setByteStreamSource(SimpleParsedEntityFactory.java:281)
at com.ibm.xml.xlxp2.api.sax.impl.SAX2ParsedEntityFactory.readFromInputSource(SAX2ParsedEntityFactory.java:122)
at com.ibm.xml.xlxp2.api.sax.impl.SAX2ParsedEntityFactory.createParsedEntity(SAX2ParsedEntityFactory.java:76)
at com.ibm.xml.xlxp2.api.stax.XMLStreamReaderImpl.setDocumentEntity(XMLStreamReaderImpl.java:394)
... 58 more
EDIT: More information.. The webservice is returning the response. It seems websphere is not able to handle the response i.e, fails with exception specified in the question.
Please help.
The exception is because of the invalid response header *text/xml;charset:UTF-8*. It supposed to be *text/xml;charset=UTF-8*
. IBM JDK is more strict in parsing whereas Oracle JDK is not. Hope this helps if anybody facing exception similar to "java.io.UnsupportedEncodingException: text/xml" in Websphere application server while calling any external webservice .