views:

2691

answers:

5

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&amp;quot;&amp;gt;&amp;lt;img alt=&quot;flickr&quot; src=&quot;http://www.flickr.com/images/flickr_logo_blog.gif&amp;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.

+1  A: 

Use UTL_HTTP

You can use the UTL_HTTP package to do this.

UTL_HTTP.read_text(
   r     IN OUT NOCOPY resp,
   data  OUT NOCOPY VARCHAR2,
   len   IN PLS_INTEGER DEFAULT NULL);

*"The UTL_HTTP package supports HTTP 1.1 chunked transfer-encoding. When the response body is returned in chunked transfer-encoding format as indicated in the response header, the package automatically decodes the chunks and returns the response body in de-chunked format."*

http://download.oracle.com/docs/cd/B10500_01/appdev.920/a96612/u_http.htm

Mark Harrison
That works great if I am making the request and parsing the response, but my pl/sql procedure is the receiver of a request. I think that mod_plsql can't handle the request, causing the http 400 error - my package doesn't even log that an attempt was made. Am I wrong?
MojoMark
A: 

I'm encountering the same issue MojoMark was (though with a different external application). MojoMark's follow up comment is correct, the read_text information does not answer the question.

Like MojoMark, I am attempting to RECEIVE a POST from an external entity. The PLSQL I'm trying to write is to receive that POST and store it.

I was able to write the outbound POST XML with no problem, but have been unable to set up a procedure to receive it.

The issue appears to be the PLSQL procedure wants a variable name, ie: http://server/modplsql/testload, POST "data='data'"

However, the body of the POST is just an XML data stream, no "=" assigning a value to a parameter, so the function gets the "Mismatch or Missing '='"" error.

It seems like there should be a way to tell MODPLSQL to just accept accept the post data like a "typical" function call, but I think I'm missing something obvious.

The basics function I'm trying to use to receive the post is: procedure testload ( DATA in clob ) as BEGIN htp.print('Input POST stream was ' || DATA )
end testload;

A: 

The only significant difference I can see between the two requests is the "Expect: 100-continue" business. This appers to be a clause in the HTTP 1.1 specification which allows the client to split the request in two. Basically, the client sends the header to the server, and the server must make a choice. If it is "happy" with the header it will give a HTTP 100 response to indicate that the rest of the message will be accepted.

Since you're getting data from Flickr, I'm not sure what level of control you have over the http requests being made by the client. From the server side it may be necessary to make a configuration change to Apache, or it may be a bug in mod_plsql that's popping up with the "!" flexible parameter marker.

Either way, the current blogger api is not like this. You probably should move to the new GData API.

Adam Hawkes
+1  A: 

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.

MojoMark
A: 
John Flack