Skip to Content
author's profile photo Former Member
Former Member

[Fatal Error] :-1:-1: Premature end of file.

Hi

I am referring this blog:

/people/siva.maranani/blog/2005/09/15/push-data-to-mvc-architectured-application-using-xi

I am doing a HTTP Receiver adapter.

I developed an Enterprise module and deployed onto Weblogic server, in weblogic server's console am getting this error:[Fatal Error] :-1:-1: Premature end of file.

I am using a HTTP Client prog to test. These are the params that iam giving in Client:

Server Host:server Port:8000

Sender Service: FTH_BS Interface:Name_MI

InterfaceNamespace:htpp://httpdemo.com

XML Payload:

<?xml version="1.0" encoding="UTF-8"?>

http://httpdemo.com">

<Name>aaa</Name>

</ns0:Name_MT>

===========

My servlet which should receive the name in XML payload and displays.

public class Response extends HttpServlet {

protected void doGet(

HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException {

doPost(request,response);

}

protected void doPost(

HttpServletRequest req,

HttpServletResponse res)

throws ServletException, IOException {

res.setContentType("text/xml;charset=UTF-8");

PrintWriter out = res.getWriter();

String Name = parseXML(req);

String SalName = Saluation(Name);

out.println(contructXML(SalName));

}

public String parseXML(HttpServletRequest req){

StringBuffer inputXML = new StringBuffer();

String Name="";

try{

BufferedReader in = req.getReader();

String line = null;

while( (line = in.readLine()) != null){

inputXML.append(line);

}

}catch(Exception ex){

}

StringReader strReader = new StringReader(inputXML.toString());

InputSource inputsource = new InputSource(strReader);

try{

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();

DocumentBuilder builder = factory.newDocumentBuilder();

Document document = builder.parse(inputsource );

NodeList Name_nlist = document.getElementsByTagName("Name");

Node Name_node = Name_nlist.item(0);

Element Name_Ele = (Element)Name_node;

Name = Name_Ele.getFirstChild().getNodeValue();

}catch(Exception ex){

}

return Name;

}

public String contructXML(String SalName){

StringBuffer output = new StringBuffer();

output.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");

output.append(" http://filetohttp.com\">");

output.append("<SalName>");

output.append(SalName);

output.append("</SalName>");

output.append("</ns0:name_MT>");

return output.toString();

}

public String Saluation(String Name){

return "Hai "+Name ;

}

}

Help me, Thanks

Regards,

ganesh

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jun 16, 2006 at 06:30 AM

    The error you are getting is an XML parsing error. For sure the XML you are constructing and feed to the statement

    StringReader strReader = new StringReader(inputXML.toString());

    is invalid. Check the contents of inputXML variable by printing it and may be validating the xml in tool like XML spy or for that matter a simplest one being Internet Explorer.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.