我有这样的代码:
AxiomSoapMessage message = (AxiomSoapMessage)webServiceMessage;
SoapHeader soapHeader = message.getSoapHeader();
SOAPMessage soapMessage = message.getAxiomMessage();
TransportContext transContext = TransportContextHolder.getTransportContext();
HttpServletConnection connection = (HttpServletConnection)transContext.getConnection();
HttpServletRequest httpRequest = connection.getHttpServletRequest();
InputStream inputStream = httpRequest.getInputStream();
SniffedXmlInputStream sniffedXmlInputStream = new SniffedXmlInputStream(inputStream);
String encoding = sniffedXmlInputStream.getXmlEncoding();
sniffedXmlInputStream.close();
String soapVersion = message.getVersion().toString();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
**soapMessage.serialize(baos);** //THIS LINE
这是接收Spring ws的 WebServiceMessage 的类的一部分,我从中提取 SOAPMessage ,如上所示。
在上面代码中标有“THIS LINE”的粗体行中,我“有时”得到以下异常
org.springframework.integration.MessageHandlingException:
org.apache.axiom.om.OMException:
javax.xml.stream.XMLStreamException:
ParseError at [row,col]:[1,4090] Message: Stream closed
任何解决方案?
答案 0 :(得分:0)
由于XML无效,可能会发生javax.xml.stream.XMLStreamException。打印XML并查看它是否针对DTD或XSD进行验证。