When the following error occurs in a SOAP request:
<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>
Because SOAP requests do not clearly specify the length of the Request package, the server cannot completely read the request package, and the server mistakenly considers the XML file of the request to be incomplete.
You only need to explicitly write the length of the Request package.CodeAs follows:
Out. println ("Content-Length: 257 ");