0

我有使用 spring-ws 库来响应肥皂请求的工作代码。我将此代码移至另一个项目(我正在合并项目),现在它失败了。我想弄清楚失败的原因。

我得到的症状是:当 HTTP 请求到达时,spring 开始处理调用。然后我得到以下异常:

org.springframework.ws.soap.saaj.SaajSoapEnvelopeException: Could not access envelope: java.io.IOException: Stream closed; nested exception is javax.xml.soap.SOAPException: java.io.IOException: Stream closed
    at org.springframework.ws.soap.saaj.SaajSoapMessage.getEnvelope(SaajSoapMessage.java:109)
        <<more lines that don't matter>>
Caused by: java.io.IOException: Stream closed
    at java.io.PushbackInputStream.ensureOpen(PushbackInputStream.java:57)
    at java.io.PushbackInputStream.read(PushbackInputStream.java:116)
    at org.apache.xerces.impl.XMLEntityManager$RewindableInputStream.read(Unknown Source)
    at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
    ... 30 more

在调试器中检查它,似乎 spring 成功地处理了 HTTP 标头,但是当它开始处理 SOAP 消息本身的内容时,它在读取正文的第一个字符时阻塞。一些谷歌搜索错误消息表明问题在于显然用于从套接字读取的 PushbackInputStream 被读取两次,或者可能调用了 close() ,然后被读取。

它发生在 spring-ws 内部,而不是我的代码中,因为在我将代码移动到新项目之前它运行良好,它必须与 spring 的版本有关,或者它使用的东西,如轴或 xerces。但我找不到这些版本的任何差异!有没有人遇到过这个错误?或者您对我在解决此问题时可以采取的方法有什么建议吗?

4

2 回答 2

1

最终决议:

事实证明,问题根本不在服务器上。相反,我用来发送请求的工具 (SoapUI) 有问题。非常感谢 Knife-Action-Jesus 建议我调查一下。

于 2010-06-17T14:29:09.880 回答
1

我的猜测是,在您尝试读取消息正文之前,某些东西正在读取流。这是典型的情况。

如果有其他东西正在读取流,它可能会消耗整个流并调用 flush() 和 close() ,这会导致您遇到这种情况。

您是否在两端放置了嗅探器并观察到肥皂消息实际上包含一个主体?这不太可能 imo 因为流实际上已关闭并抛出空指针或任何东西。

于 2010-06-16T20:19:59.440 回答