on 06-16-2006 5:44 AM
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"?>
<ns0:Name_MT xmlns:ns0="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("<ns0:name_MT xmlns:ns0=\"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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.