Receiving an XML Post / Variables Posted in

Posted on 2005-05-09
Medium Priority
Last Modified: 2013-12-25
Hi there,

I am receiving an XML post from a 3rd party server, and I am "reading in" all the content posted to my script, then writing the content to a .xml file on my server for processing.

It appears to work on initial looking, however upon closer inspection, the base64 code is being corrupted, and there are various charcters that are being changing from the original post, such as a + character.

For example, in the original post, the string is like so:

<field name="Remote" type = "string">+447796170669</field>

However after receiving/writing via my perl script, the text is written:

<field name="Remote" type = "string"> 447796170669</field>

(loosing the + character) so Im guessing a similar thing is happening with the base64 code.

The way I am harnessing the data posted is using the following script:

@names = $q->param;
foreach $varname (@names)
{ $$varname = $q->param($varname);
$output.= $q->param($varname);

Then writing the $output variable to a file. Is there a better solution here that may help me out with this corrupting data?

Question by:scooter41
  • 3
  • 2
LVL 51

Accepted Solution

ahoffmann earned 2000 total points
ID: 13961917
if you transmit a + character over HTTP the receiving web server translates it to a space
you need to HTML- or URL-encode the + as %2b before transmitting

Author Comment

ID: 13963375
hmm unfortunaley I dont have control of the posting server, maybe if its not possible in perl, i will have to look at another language?
LVL 48

Expert Comment

ID: 13963531

use CGI;
my $q = new CGI;

my @params = $q->param;

open FILE, ">/some/file.xml" or die "Can not open file.xml $!\n";

foreach my $param (@params) {
  print FILE "$param=" . $q->param($param) . "\n";

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 13966085
Hey Tintin.

Thanks for the idea, but unfortunely it produced exactly the same output :(

Thanks again.

LVL 51

Expert Comment

ID: 13966525
the posted CGI is on the recievig server?
Then you should not use CGI 'cause it translates the URL/HTML-encoding
You need to read the raw data from $env{QUERY_STRING} or STDIN and then convert yourself
But again: the sender should not send + verbatim
LVL 51

Expert Comment

ID: 14208890
I still believe in my first suggestion

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses
Course of the Month16 days, 11 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question