Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
POSTing XML to a CGI
chuckles
I am trying to put together an ad hoc web service using Perl and CGI.pm. The client is sending a POST to the CGI where the content is an XML string. Problem is that once I initialize a new CGI object, it immediately tries to parse out the posted content as if it were url encoded name/value pairs. Is there some way I can tell CGI.pm not to parse the POST data and give it to me directly? Would it be done via the module or in the request headers?
Find more posts tagged with
Comments
Migrateduser
That sounds strange... how are you parsing it and at what point exactly is it parsing the content?
Dave
Current Environment(s):
(1) TS 6.5 on W2K3
(2) TS 6.1 SP1 on W2K3
chuckles
I don't think it is strange. This is actually being proposed as part of Web Forms 2.0
http://www.w3.org/Submission/web-forms2/#x-www-form-xml
.
Either way, I got this working without CGI.pm by just examing the %ENV hash to read the request method, content type, content length, etc and then just reading the XML data from STDIN and sending to a parser. It worked fine, but I want to add some features and robustness to the script and I would rather use CGI.pm than reinvent the wheel. The main stopping point is that once I call CGI->new(), I can't access STDIN anymore. I just want to know if there is some way to access the POST data after the call to new() either via a pragma or request header or something.
Edited by chuckles on 04/28/05 09:39 AM (server time).
Migrateduser
If not, how would you feel about reconstructing the input based on the parsed info you're getting? It's not the cleanest by any means, but it's the most immediate solution that comes to my head.
Dave
Current Environment(s):
(1) TS 6.5 on W2K3
(2) TS 6.1 SP1 on W2K3
chuckles
Ah-ha! I got it in my head that if I monkeyed with CGI.pm, I could bend it to my will. Lo and behold, someone beat me to it and inserted an undocumented feature to handle XML posts. If the method is 'POST' and the content type is neither application/x-www-form-urlencoded nor multipart/form-data it just stuffs the entire post into a param called POSTDATA. I did a quick test and it works. Maybe I should e-mail Dr. Stein to update his pod...
Migrateduser
Good... that's the part that seemed strange to me. A POST shouldn't automatically be encoded like that but I'm glad you found it.
Dave
Current Environment(s):
(1) TS 6.5 on W2K3
(2) TS 6.1 SP1 on W2K3