2

I am tasked to setup a webserver which listens for incoming HTTP POST requests that contain xml content. upon receiving POST request, Web server should parse the xml content and insert extracted data in to database.

I have setup an Apache(version 2.2) server on centos and written simple python cgi that will get called when post request is received.

In python script I could access predefined attributes (eg: query string, cookies etc..) via environment variables. but couldn't figure out how to access xml content in python code!

Hope you guys could let me know how to access xml content in python cgi script.

<?xml version="1.0" encoding="utf-8"?>
<Events xmlns:i="http://www.w3.org/2001/XMLSchema-instance2" xmlns="http://schemas.datacontract.org/2004/07/foo.Web.Impl.Services.Data">
    <Event>
       <EventType>AORCreated</EventType>
       <EventID>c3a09825-38b6-499f-81fc-9f821e4695ed</EventID>
       <UserID>743d61a2-d8da-431c-8aa4-70912dd00ecb</UserID>
       <LicenseeID>1</LicenseeID>
       <Culture>en-GB</Culture>
       <Properties>
          <Property>
             <Key>AOR</Key>
             <Value>[email protected]</Value>
          </Property>
       </Properties>
     </Event>
</Events>

Thanks in advance, Prasun

1 Answer 1

1

this did it

import cgi
form = cgi.FieldStorage()
form.value

form.value contains the content of post requests body

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.