Soap: The root element is required in a well-formed document.

當soap請求出現如下錯誤的時候:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header/>
<soapenv:Body>
<soapenv:Fault>
<faultcode>soapenv:Server.generalException</faultcode>
<faultstring>org.xml.sax.SAXParseException: The root element is required in a well-formed document. Message being parsed: </faultstring>
</soapenv:Fault>
</soapenv:Body>
</soapenv:Envelope>

是因爲soap的請求沒有明確寫出請求包的長度,使server端不能完整讀取請求包,server端便錯誤的認爲請求的xml文件不完整。


只要明確的寫上請求包得長度即可,java代碼如下:

out.println("Content-Length: 257");


發佈了36 篇原創文章 · 獲贊 2 · 訪問量 15萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章