Receiving an XML Post / Variables Posted in

Posted on 2005-05-09
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
    LVL 51

    Accepted Solution

    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

    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


    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";


    Author Comment

    Hey Tintin.

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

    Thanks again.

    LVL 51

    Expert Comment

    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

    I still believe in my first suggestion

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    Suggested Solutions

    Title # Comments Views Activity
    Powershell Script 8 60
    PHP 7 2 37
    Exchange 2013 - report system 2 34
    Batch FIle delete files with particular date 10 30
    The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
    Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
    The viewer will learn how to count occurrences of each item in an array.
    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…

    759 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

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now