2013-05-14 48 views
0

我們正在開發Web服務解決方案。 webservice API爲我們提供了幾個調用,我們可以使用它們從客戶端WebService實現中檢索SOAP響應。SAXParseException與AXIS Webservice Framework

該實現基於AXIS框架。

所有的API調用都能很好地工作,除非我們在返回響應時遇到SAXParseException。

當我們在SOAP UI中嘗試時,我們得到了針對這個特定API的有效響應。但是當我們在Java項目中嘗試時,我們得到了這個SAXParseException。 Java和SOAP用戶界面項目都是使用相同的WSDL文件創建的

請查看下面的堆棧跟蹤並分享您的卑微觀點,看看這裏可能出現了什麼問題。

XML received: 
2013-05-14 12:12:20,536 DEBUG http-bio-8080-exec-1 org.apache.axis.transport.http.HTTPSender - ----------------------------------------------- 
2013-05-14 12:12:20,536 DEBUG http-bio-8080-exec-1 org.apache.axis.SOAPPart - Enter: SOAPPart::getAsSOAPEnvelope() 
2013-05-14 12:12:20,536 DEBUG http-bio-8080-exec-1 org.apache.axis.i18n.ProjectResourceBundle - org.apache.axis.i18n.resource::handleGetObject(currForm) 
2013-05-14 12:12:20,536 DEBUG http-bio-8080-exec-1 org.apache.axis.SOAPPart - current form is FORM_INPUTSTREAM 
2013-05-14 12:12:20,708 DEBUG http-bio-8080-exec-1 org.apache.axis.transport.http.HTTPSender - org.xml.sax.SAXParseException: The root element is required in a well-formed document. 
2013-05-14 12:12:20,708 DEBUG http-bio-8080-exec-1 org.apache.axis.SOAPPart - Enter: SOAPPart ctor(FORM_FAULT) 
2013-05-14 12:12:20,708 DEBUG http-bio-8080-exec-1 org.apache.axis.i18n.ProjectResourceBundle - org.apache.axis.i18n.resource::handleGetObject(setMsgForm) 
2013-05-14 12:12:20,708 DEBUG http-bio-8080-exec-1 org.apache.axis.SOAPPart - Setting current message form to: FORM_FAULT (currentMessage is now org.apache.axis.AxisFault) 
2013-05-14 12:12:20,708 DEBUG http-bio-8080-exec-1 org.apache.axis.SOAPPart - Exit: SOAPPart ctor() 
2013-05-14 12:12:20,708 DEBUG http-bio-8080-exec-1 org.apache.axis.i18n.ProjectResourceBundle - org.apache.axis.i18n.resource::handleGetObject(toAxisFault00) 
2013-05-14 12:12:20,740 DEBUG http-bio-8080-exec-1 org.apache.axis.enterprise - Mapping Exception to AxisFault 
AxisFault 
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException 
faultSubcode: 
faultString: org.xml.sax.SAXParseException: The root element is required in a well-formed document. 
faultActor: 
faultNode: 
faultDetail: 
    {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXParseException: The root element is required in a well-formed document. 
    at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1213) 
    at org.apache.xerces.framework.XMLDocumentScanner.reportFatalXMLError(XMLDocumentScanner.java:570) 
    at org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.endOfInput(XMLDocumentScanner.java:790) 
    at org.apache.xerces.framework.XMLDocumentScanner.endOfInput(XMLDocumentScanner.java:418) 
    at org.apache.xerces.validators.common.XMLValidator.sendEndOfInputNotifications(XMLValidator.java:712) 
    at org.apache.xerces.readers.DefaultEntityHandler.changeReaders(DefaultEntityHandler.java:1031) 
    at org.apache.xerces.readers.XMLEntityReader.changeReaders(XMLEntityReader.java:168) 
    at org.apache.xerces.readers.AbstractCharReader.changeReaders(AbstractCharReader.java:150) 
    at org.apache.xerces.readers.AbstractCharReader.lookingAtChar(AbstractCharReader.java:217) 
    at org.apache.xerces.framework.XMLDocumentScanner$XMLDeclDispatcher.dispatch(XMLDocumentScanner.java:686) 
    at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381) 
    at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1098) 
    at javax.xml.parsers.SAXParser.parse(Unknown Source) 
    at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227) 
    at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696) 
    at org.apache.axis.Message.getSOAPEnvelope(Message.java:435) 
    at org.apache.axis.transport.http.HTTPSender.readFromSocket(HTTPSender.java:796) 
    at org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144) 
    at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32) 
    at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118) 
    at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83) 
    at org.apache.axis.client.AxisClient.invoke(AxisClient.java:165) 
    at org.apache.axis.client.Call.invokeEngine(Call.java:2784) 
    at org.apache.axis.client.Call.invoke(Call.java:2767) 
    at org.apache.axis.client.Call.invoke(Call.java:2443) 
    at org.apache.axis.client.Call.invoke(Call.java:2366) 
    at org.apache.axis.client.Call.invoke(Call.java:1812) 

回答

3

看來你沒有得到有效的XML響應......類似的東西。

<?xml version="1.0"?> 
<node1> 
... bla, bla 
</node1> 
<node2> 
... bla, bla 
</node2> 
<node_x> 
... bla, bla 
</node_x> 

,而不是...

<?xml version="1.0"?> 
<node1> 
    <node2> 
    ... bla, bla 
    </node2> 
    <node_x> 
    ... bla, bla 
    </node_x> 
</node1> 

你應該嗅探網絡流量以原始格式的內容。如果有人用手工構造xml代碼而不用熟知的工具,我通常會得到這個錯誤。

+0

是的,即使我這麼認爲。我們仍然有同樣的錯誤。當我們在SOAP用戶界面中嘗試時,我們得到了對這個特定API有效的響應但是當我們嘗試使用Java時,我們會遇到這個錯誤。 Java和SOAP UI項目都是使用相同的WSDL文件創建的 – tiger 2013-05-15 09:02:32