You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by Donald Dade <do...@hotmail.com> on 2001/03/30 04:20:55 UTC

Problems with incorrect HTTP content-length due to CR/LF pairs

Hello list,

I am using Linux Mandrake 7, JDK 1.3, Apache SOAP 2.1, and Xerces-J 1.3.1 in 
a simple program that sends a SOAP message to a perl app on a Windows NT 
box.

The perl script constantly is unable to parse and deserialize my message. 
>From a tcp dump I can see that the HTTP header reports a content length of 
690 bytes, while the actual length of the content is 706 bytes. This 
difference of 16 bytes is exactly equal to the number of lines in the XML 
contained in the SOAP envelope, suggesting that there is something at the 
end of every line, like a superfluous LF character.

As additional evidence, if I take a transcript of a message without the 
CR/LF pairs, from another source, and simply dump it to the same URL using a 
TCP socket, the message is parsed successfully.

So, my question is this: Are there issues with the Xerces parser, and how it 
treats CR/LF pairs in its output that would cause it to mis-report the 
length of the XML representing the envelope? Has anyone had any experience 
with this issue?

Any assistance would be much appreciated,

Don Dade
ddade@digitalstatecraft.com
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


Re: Problems with incorrect HTTP content-length due to CR/LF pairs

Posted by Scott Nichol <sn...@computer.org>.
Donald,

I have not looked at the LF v. CR/LF characteristics of Apache SOAP before.  Looking at
the Envelope.java source, which is responsible for writing the XML body, I see that it
uses StringUtils.lineSeparator to terminate lines.  StringUtils initializes this as
System.getProperty("line.separator", "\n").  I don't have Mandrake Linux available, but
a quick look at Digital UNIX shows this is a single LF.  The simple code for this is

public class LineSeparator {
    public static void main(String[] args) {
        String lineSeparator = System.getProperty("line.separator");
        System.out.println("Length " + lineSeparator.length());
        for (int i = 0; i < lineSeparator.length(); i++)
            System.out.print((int) lineSeparator.charAt(i));
        System.out.println();
    }
}

I suspect that you would find the same result on your system.  Therefore, I believe your
SOAP client may actually be sending a 690 byte message as reported, but something else
is changing the LF to CR/LF.  My installation of Active State's Perl on NT does *not*
make this change with read or sysread, though, so I don't have a good idea of where the
change is happening to you.

Scott Nichol

----- Original Message -----
From: "Donald Dade" <do...@hotmail.com>
To: <so...@xml.apache.org>
Sent: Thursday, March 29, 2001 9:20 PM
Subject: Problems with incorrect HTTP content-length due to CR/LF pairs


> Hello list,
>
> I am using Linux Mandrake 7, JDK 1.3, Apache SOAP 2.1, and Xerces-J 1.3.1 in
> a simple program that sends a SOAP message to a perl app on a Windows NT
> box.
>
> The perl script constantly is unable to parse and deserialize my message.
> From a tcp dump I can see that the HTTP header reports a content length of
> 690 bytes, while the actual length of the content is 706 bytes. This
> difference of 16 bytes is exactly equal to the number of lines in the XML
> contained in the SOAP envelope, suggesting that there is something at the
> end of every line, like a superfluous LF character.
>
> As additional evidence, if I take a transcript of a message without the
> CR/LF pairs, from another source, and simply dump it to the same URL using a
> TCP socket, the message is parsed successfully.
>
> So, my question is this: Are there issues with the Xerces parser, and how it
> treats CR/LF pairs in its output that would cause it to mis-report the
> length of the XML representing the envelope? Has anyone had any experience
> with this issue?
>
> Any assistance would be much appreciated,
>
> Don Dade
> ddade@digitalstatecraft.com
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com
>
>