简体   繁体   中英

HTTP response unrecognized text

I have a lotus notes java agent in which I receive a XML, parse it and send a response back with XML as content:

                pw.println("Content-Type: text/xml");
                pw.println("charset: UTF-8");
                pw.print("\r\n");
                pw.println("<cXML payloadID=\"" + payload + "\" xml:lang=\"en\"" + " timestamp=\"" + timestamp + "\" >" + "<Response><Status code=\"200\" text=\"OK\" /></Response></cXML>"  );

I checked how the response content will look like and i see this:

<cXML payloadID="1449750433..595@" xml:lang="en" timestamp="2015-12-10T12:27:13"><Response><Status code="200" text="OK"/></Response></cXML>

but if i check wireshark then I see this:

在此输入图像描述

Why I get this unrecognized text.

And B the receiving host which gets my response back is an .net application, this .net application receives this error: 在此输入图像描述

Anyone that can help me.

Thank you

Changed code to:

                  pw.println("Content-Type: text/xml; charset=utf-8\r\n"); 

                 pw.println("<cXML payloadID=\"" + payload + "\" xml:lang=\"en\"" + " timestamp=\"" + timestamp + "\" >" + "<Response><Status code=\"200\" text=\"OK\" /></Response></cXML>"  );

HTTP headers require CR+LF (Windows-style) line endings. Try putting the line endings in manually, eg:

pw.print("Content-Type: text/xml\r\n");

and then mark the end of the header with an empty line:

pw.print("\r\n");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM