cancel
Showing results for 
Search instead for 
Did you mean: 

XML file is not being displayed in browser? Why?

Former Member
0 Kudos

Hi all!

I have a secnario file->XI->J2EE appl.

I am using File sender adapter and HTTP Receiver adapter.

I placed XML file in D:\somedir of my machine, it is picking up well by XI, <b>all i want to know is how XI sends this XML file to my J2EE Appl.</b>Because my servlet should display the same XML file in browser. I deployed my J2EE appl on weblogic application server9.0 I am getting the following error:

The XML page cannot be displayed

Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.

-


XML document must have a top level element. Error processing resource 'http://localhost:7001/Invoke/DisplayRes'.

These are settings that i have given in my Receiver HTTP adapter:

Aadapter Type: HTTP

Receiver

Transport Protocol: HTTP1.0

Message Protocol: XI payload in HTTP body

Adapter Engine: Integration Server

Addressing Type: URL address

Target host: localhost

Service Number: 7001(Port number of Weblogic appl server--where my J2EE appl is deployed).

Path : /Invoke/DisplayRes/(Context path of J2EE appl)

Authentication Type:Use Logon Data for SAP System

Content Type: text/xml

Username: xiappluser

password: xx

XML code: UTF-8

This is my Servlet code:

public class DisplayRes extends HttpServlet {

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

{

doPost(request,response);

}

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

{

BufferedReader brin =new BufferedReader(new InputStreamReader(request.getInputStream()));

String inputLine;

StringBuffer sBuf = new StringBuffer();

PrintWriter out = response.getWriter();

response.setContentType("text/xml");

while ((inputLine = brin.readLine()) != null)

sBuf.append(inputLine);

out.println(sBuf.toString());

brin.close();

out.flush();

}

}

Where i went wrong please help me,

NOTE: I want to know how XI sends XML file to my J2EE appl. I suppose my servlet receives it in request object.If so can i use like:

response.setContentType("text/xml");

String xmlFile = request.getParameter("myXMLFile");

PrintWriter out = response.getWriter();

out.write(xmlFile);

out.flush();

out.close();

Please help me!

Thanks a lot!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Datta,

You seem to have big problem with this scneario as you have raised this question couple of times , in couple of topics / threads. I will try to make a few things about this clear.

1. XI when sends data to a J2EE application , in your case a servlet, I believe you must be using a HTTP adapter to post the data to it. Whenever XI will post a XML data to a HTTP resource , it will post it as the request body and that is why the code in one of my previous post reads,

BufferedReader brin =new BufferedReader(new InputStreamReader(request.getInputStream()));
String inputLine;
StringBuffer sBuf = new StringBuffer();
PrintWriter out = response.getWriter();
response.setContentType("text/xml");
while ((inputLine = brin.readLine()) != null) 
sBuf.append(inputLine);
out.println(sBuf.toString());
brin.close();
out.flush();

If you 've noticed, the statement

request.getInputStream()

retrieves the body of the request as binary data using a ServletInputStream.

So your answer to your question is

<b>XI transferes data to a servlet as a part of HTTP request body</b>, if you use a HTTP adapter.

2. By J2EE application , if you mean a server java proxy, then the method whose name matches with that of the Inbound Message interface recieves a parameter , from which you can retrieve the parameters passed by XI. Just check the getters of that object.

Hope this clears your basic doubts!!!

Rgds,

Amol

Former Member
0 Kudos

Hi

I got this in my browser, which says, the code is not able to retrieve the XML message sent from XI or what..?

when i gave the following in my IE browser:

http://localhost:7001/Invoke/DisplayRes/

<ns0:purchase_order_MT xmlns:ns0="http://filetohttp.com">null</ns0:purchase_order_MT>

Help me

Thanks

Former Member
0 Kudos

Hi

I got this in my browser, which says, the code is not able to retrieve the XML message sent from XI or what..?

when i gave the following in my IE browser:

http://localhost:7001/Invoke/DisplayRes/

<ns0:purchase_order_MT xmlns:ns0="http://filetohttp.com">null</ns0:purchase_order_MT>

The corresponding Servlet code:

public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException

{

PrintWriter out = response.getWriter();

BufferedReader brin =new BufferedReader(new InputStreamReader(request.getInputStream()));

String inputLine;

StringBuffer sBuf = new StringBuffer();

response.setContentType("text/xml");

while ((inputLine = brin.readLine()) != null)

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

sBuf.append("<ns0:purchase_order_MT xmlns:ns0=\"http://filetohttp.com\">");

sBuf.append(inputLine);

sBuf.append("</ns0:purchase_order_MT>");

out.println(sBuf.toString());

System.out.println("XML output is "+sBuf.toString());

brin.close();

out.flush();

Help me

Thanks

Answers (0)