Written by

Question Paul Riker · Jul 6, 2016

White Space between http header and text

I am writing a static SOAP response to simply test connectivity. The end users is getting an error "Message: The processing instruction target matching [xX][mM][lL] is not allowed.", which I believe is related to white space. if I observe the response, it looks like there are two blank lines between the header and the body, which I'm guessing is the white space problem. But I can't seem to get rid of it.

Any ideas?

Code:

<script language="Cache" method="OnPreHTTP" arguments="" returntype="%Boolean">
     Set %response.ContentType = "text/xml"
    Quit 1</script>
<?xml version="1.0" encoding="UTF-8" ?>

 

Result:

HTTP/1.1 200 OK
Date: Wed, 06 Jul 2016 19:54:27 GMT
Server: Apache/2.2.15 (CentOS)
SET-COOKIE:  httpOnly;
CACHE-CONTROL: no-cache
EXPIRES: Thu, 29 Oct 1998 17:04:19 GMT
PRAGMA: no-cache
SET-COOKIE: 
CONTENT-LENGTH: 509
Connection: close
Content-Type: text/xml; charset=utf-8


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

Comments

Alexander Koblov · Jul 6, 2016

I wonder if this extra line is caused by the line break between </script> and the xml header.

Can you try to move

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

Before <script> ?

0
Mark Hanson · Jul 7, 2016

Try:

<script language="Cache" method="OnPreHTTP" arguments="" returntype="%Boolean"
     Set %response.ContentType "text/xml"
    Quit 1</script><?xml version="1.0" encoding="UTF-8" ?>

As the cr/lf after the </script> will end up in the output we generate as this is part of the HTML output rather than inside the script itself.

0
Paul Riker  Jul 7, 2016 to Mark Hanson

Bingo! Thanks, you and Alexander both lead me to the resolution. 

0