cancel
Showing results for 
Search instead for 
Did you mean: 

How to display an XML file as it is in browser that XI sent to my J2EE appl

Former Member
0 Kudos

Hi all!

I have a scenario like File->XI->J2EE appl.

The file is getting picked up from my machine by XI.

Now XI should send that XML file to my J2EE appl.

My servlet receives that XML and displays as it is in browser. But am getting some error like:

XML page cannot be displayed.

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

I deployed my .ear file on BEA Weblogic application server9.0

I found no error when i tested in SXI_MONI and RWB->Message monitor as well.

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.setContentType("text/xml");

//out.println(sBuf.toString());

out.write(sBuf.toString());

brin.close();

out.flush();

}

}

what went wrong? Help me

Thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Datta,

Error indicates your final XML structure is not correct. Its missing some element which result in error.

You can copy or download XML message from SXMB_MONI and try to open same (.xml file) in XML spy ( XML tool). You can download this software from net and is free.

Hope this will help you to solve problem.

Cheers,

Nilesh

Former Member
0 Kudos

HI Datta,

Please can you check if your program is invoked. I think because the XML is not formed well its not invoking the J2EE application and you are not getting any errors

Regards

Vijaya

Former Member
0 Kudos

Hi how to check whether my J2EE application(Servlet) is invoked or not?

How to check that?

Help me

Thanks

Former Member
0 Kudos

Very simple.Put some log statements in your servlet!!

If you are not aware of how to enable logging / tracing in J2EE applications in WebAS then just put System.out statements in your servlet which would be sent to your defaultTrace.trc file in WebAS. You need to do some configurations in visual administrator for the same.

Former Member
0 Kudos

I placed System.out.println() statements in my servlet

Nothing is displayed in my console.

Help me

Former Member
0 Kudos

As mentioned in my previous post you need to change a few settings using Visual administrator.

Log on to Visual administrator and

1. Select the LogConfigurator Service in the Cluster/Server/Services/LogConfigurator Node

2. Select the Locations Tab.

3. Expand and select ROOT LOCATION/System/out.

4. Select Severity: "All".

5. Save your changes by clicking the disk symbol.

<b>Reward helpful answers!!!</b>

Former Member
0 Kudos

Hi

Can anyone tell me how XI sends messages to applications like J2EE. In REceiver comm channel, I think we specify about the target system like J2EE appl.

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/

Authentication Type:Use Logon Data for SAP System

Content Type: text/xml

Username: xiappluser

password: xx

XML code: UTF-8

I suppose XI sends msgs to http://localhost:7001/Invoke/DisplayRes/.

in this example if am correct?

Then I have given all tyhe necessary setting but my servlet is not able to display XML msg in browser?

This is my 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(inputLine);

out.println("hi");

out.println(sBuf.toString());

brin.close();

out.flush();

}

What went wrong?

Help me, all helpful answers are highly rewarded.

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>

Help me

Thanks

moorthy
Active Contributor
0 Kudos

Hi Datta,

<i>XML page cannot be displayed.

XML document must have a top level element.</i>

Check your XML output from XI is well Structured ? Pick up the XML file from the XI and check in XML SPy or any xml editors is it correct format or not..

Or Even you can give that input to your java application and check independently..as an Independent application..

Thanks,

Moorthy

Former Member
0 Kudos

Hi

I opened the same XML in IE6.0, it is well formed

This is my XML file that am giving as input for my J2EE application:

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

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

<ORDER_HEADER_IN>

<purchase_date/>

<purchase_group/>

<purchase_org/>

</ORDER_HEADER_IN>

<vendor/>

<ORDER_ITEMS_IN>

<item>

<storage_location/>

<plant/>

<quantity/>

<material/>

</item>

</ORDER_ITEMS_IN>

<ORDER_SCHEDULES_IN>

<item>

<delivery_date/>

</item>

</ORDER_SCHEDULES_IN>

</ns0:purchase_order_MT>

Please help me

Thanks