SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XML doc in the body of a HTTP POST: has anyone already done this?

    hi there
    i was wondering if anyone could shed some lights on how to deal with XML doc sent in the body of a HTTP POST. I would like to have two applications communicating with each other, XML and HTTP POST would be the bridge between these two apps.

    thanks in advance

  2. #2
    SitePoint Addict
    Join Date
    Apr 2004
    Location
    Regina, SK
    Posts
    318
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are plenty of built in functions for handling XML in PHP. Retrieving it from POST var should be no more difficult then retrieving any other variable. The PEAR repository has some HTTP classes for creating POST vars if that's what your having problems with (http://pear.php.net).
    Reduce or eliminate spam on your sites without CAPTHCAs
    - maybe it is possible: http://formantispam.thekerrs.ca/

  3. #3
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok thanks.
    In the documentation that I have, it seemed that sending XML doc in HTTP POST didn't require to retrieve it as a variable...
    I'll check that out

  4. #4
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Most XML-based clients send their output direct in the body of POST request without binding it to any variable. PHP is unable to parse that correctly, you need to have a direct access to request body ($HTTP_RAW_POST_DATA). You also need to tell php it should save this data for you (always_populate_raw_post_data=1 in php.ini). Another (and preffered since php4.3) method is to read data directly from "php://input" stream.

  5. #5
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I really feel relieved, stereofrog is now taking care of me

    I tried to find something about $HTTP_RAW_POST_DATA in the manual but just couldn't... do you have any leads to offer?

    Another (and preffered since php4.3) method is to read data directly from "php://input" stream.
    ok ok... tell me more about it. what's that "php://input" thingy?

    thanks in advance stereofrog.

    Edit:


    what if I don't have access to the php.ini file in the first scenario? can it be handled still?

  6. #6
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  7. #7
    SitePoint Wizard
    Join Date
    Jan 2005
    Location
    blahblahblah
    Posts
    1,447
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you so much

    Two more questions

    1. I will have to provide an url in order to communicate with the other app (so that the app can send the XML doc via the POST method). I'm having a hard time figuring out how to handle the incoming HTTP POST. Should my script look like:
    PHP Code:
    $incomingXML php://input; 
    and then work on the $incomingXML variable?

    2. Are there some special functions I should know in order to easily process the XML doc?

    thanks in advance for your time and thank you so much for your great help.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •