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

来源:互联网 发布:阿里云cvtm628电视机 编辑:程序博客网 时间:2024/06/08 15:09

当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");


原创粉丝点击