Parsing XML response of SOAP call in Weblogic

divoone

New Member
We are in the process of migrating functionality from a Weblogic Server 8,1 sp5 with java 1.4 to 10.3.6 with java 1.7.The case that is described below is working properly in the old server, however we are facing an issue when transferring the handling to the new one.The problem lies while retrieving and parsing an XML response that was retrieved from an external system through SOAP calls. The following libraries and procedure are used in the method:[*]java.net.HttpURLConnection to make the connection[*]java.io.OutputStream to send the request[*]java.io.InputStream to get the response[*]byte[] to store the result before transforming in to String[*]javax.xml.parsers.DocumentBuilder, java.io.StringReader and org.xml.sax.InputSource to transform the String into org.w3c.dom.Document[*]The following exception is thrown:"org.xml.sax.SAXParseException - Content is not allowed in trailing section."When opening the logs of the application with notepad++ many null characters appear after the end of the file which seem to cause the issue. I repeat that no such cases appear when executing the request from the old server.The respective code is the following:\[code\]//Creating the connectionURL u = new URL(default_server);URLConnection uc = u.openConnection();HttpURLConnection connection = (HttpURLConnection) uc;connection.setDoOutput(true);connection.setDoInput(true);connection.setRequestMethod(requestMethod);connection.setRequestProperty("SOAPAction", soap_action);OutputStream out = connection.getOutputStream();Writer wout = new OutputStreamWriter(out);wout.write(xmlString);wout.flush();wout.close();InputStream in = connection.getInputStream();int c = in.available();byte r[] = new byte[c];in.read(r);String response = new String(r);connection.disconnect();//Transorming the String to XML DocDocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();DocumentBuilder builder = factory.newDocumentBuilder();StringReader theReader = new StringReader(response);InputSource theInputSource = new InputSource();theInputSource.setCharacterStream(theReader);Document doc = builder.parse(theInputSource); //Here occurs org.xml.sax.SAXParseException-Content is not allowed in trailing sectionreturn doc;\[/code\]I know that i can solve the issue by getting the stripping the response from junk characters but this not a safe resolution.Do you have any information to share on the matter? Do you think it is a java version issue or maybe a server configuration issue?Thank you in advance your time.Best Regards,George
 
Back
Top