How to retrieve XML into Oracle PL/SQL via an HTTP Post transaction?

MojoMark picture MojoMark · Jan 17, 2009 · Viewed 10.7k times · Source

I'm trying to implement the "blog this" function from Flickr using the BloggerAPI to my pl/sql based CMS.

When Flickr sends me the posting transaction, the HTTP transaction looks like this:

POST /pls/website/!pkg.procAPI HTTP/1.1
Host: www.mydomain.com
Accept: */*
User-Agent: Flickr
Content-Type: text/xml; charset=utf-8
Content-Length: 1220
Expect: 100-continue

<?xml version="1.0" encoding="utf-8"?>
<methodCall>
    <methodName>blogger.newPost</methodName>
    <params>
        <param><value><string>NO_APP_KEY</string></value></param>
        <param><value><string>1</string></value></param>
        <param><value><string>markj</string></value></param>
        <param><value><string>markj</string></value></param>
        <param><value><string>This is a test post from &lt;a href=&quot;http://www.flickr.com/r/testpost&quot;&gt;&lt;img alt=&quot;flickr&quot; src=&quot;http://www.flickr.com/images/flickr_logo_blog.gif&quot; width=&quot;41&quot; height=&quot;18&quot; border=&quot;0&quot; align=&quot;absmiddle&quot; /&gt;&lt;/a&gt;, a fancy photo sharing thing.</string></value></param>
        <param><value><boolean>1</boolean></value></param>
    </params>
</methodCall>

But my server is responding with an HTTP-400 Bad Request and the error message is "Signature Mismatch or Missing '='" and my pl/sql procedure never gets a chance to process the request. I suspect that the flexible parameter passing is getting hosed when looking at the message, but I don't know how else

The process to get the available blogs seems to work ok, but the content of the request doesn't have all the html entities as part of the message:

    POST /pls/website/!pkg.procAPI HTTP/1.1
Host: www.mydomain.com
Accept: */*
User-Agent: Flickr
Content-Type: text/xml; charset=utf-8
Content-Length: 304

<?xml version="1.0" encoding="utf-8"?>
<methodCall>
    <methodName>blogger.getUsersBlogs</methodName>
    <params>
        <param><value><string>NO-APP-KEY</string></value></param>
        <param><value><string>mark</string></value></param>
        <param><value><string>markj</string></value></param>
    </params>
</methodCall>

Is there a way to get the xml data from the body of the http request directly? or some other approach I'm over looking?

Thanks, Mark.

Answer

MojoMark picture MojoMark · Sep 18, 2009

I opened a service request with Oracle and they confirmed that mod_plsql does not support retrieving httpheader variables. Here is the discussion I had on the SR:

ISSUE ANALYSIS

I need to confirm it, but Mark conclusion so far looks right to me,i.e. MOD_PLSQL is always invoking and processing PLSQL procedures and there is no way to read the raw HTTP request because MOD_PLSQL parses the request and checks if there is a PLSQL procedure with this name and if there are arguments to pass. If there are no arguments to pass but we are providing something else like the XML document, MODPLSQL gets puzzled and thinks this is a new pair of parameter and value when this is not really the case.

ANSWER

No, it is not possible to do it because MOD_PLSQL just treats requests with parameters which can be parsed and translated as a PLSQL procedure call with several arguments. MOD_PLSQL has no concept of a "httprequest" variable containing the whole request in the same way java has the HTTPRequest object

ISSUE ANALYSIS

Got the confirmation unless we pass it as a parameter we can not read it from MOD_PLSQL. In other words, if we pass the XML page in the HTTP request body we need to use something like java where we can treat the request in raw mode and we can read any HTTP header and the http body without restrictions of any kind.