guyenko has asked for the wisdom of the Perl Monks concerning the following question:

Oracle 11.2.0.3

Windows server 2008r2

Apache tomcat 7.0

Oracle APEX 4.2.1

Oracle APEX Listener 2.0

I would like to insert a XML document into the database through an APEX restful web service. The POST into the web service in done with PERL. The following code will insert an null record in a table with column of XMLType type, also it will do the same on a varchar2 column. Perl Code

use strict; use warnings; use LWP::UserAgent; use HTTP:Headers; my $headers = HTTP::Headers->new(); my $url = "http://host:port:apex/<application_workspace>/<restfull ser +vice module>/<uri template>/ my $sendthis = ('<?xml version="1.0" enconding="utf-8"?> <students> <row> <name>Mark</name> <age>30</age> </row> </students>';) $headers -> header('Content-Type' => 'text/xml; charset=utf-8'); my $request = HTTP:Request->new('POST', $url, $headers, $sendthis); $request-> protocol('HTTP/1.1'); my $browser = LWP::UserAgent->new(); my $response = $browser->request($request); my $gotthis= $response->content(); my $the_file_data = $response->content();

APEX restful service

Method: POST Source type: PL/SQL MIME Types allowed: blank require secure access: none source: {declare doc varchar2(32000); begin insert into table <column name> values(doc); commit; end;

Table code

{ create table <tablename> (column name XMLType>);

The above code will insert an null column into the table. Any ideas why?

  • Comment on Http Post to Oracle Apex restful web service inserts null into oracle database table with XMLType and varchar2 columns
  • Select or Download Code

Replies are listed 'Best First'.
Re: Http Post to Oracle Apex restful web service inserts null into oracle database table with XMLType and varchar2 columns
by Anonymous Monk on Oct 18, 2013 at 00:35 UTC
Re: Http Post to Oracle Apex restful web service inserts null into oracle database table with XMLType and varchar2 columns
by roboticus (Chancellor) on Oct 18, 2013 at 12:17 UTC

    guyenko:

    Update: Clearly, I'm an idiot. After posting, I tested my assumption--rather than before.

    Print out the value of $sendthis after your assignment--it doesn't contain what you think it does.

    my $sendthis = ('<?xml version="1.0" enconding="utf-8"?> <students> <row> <name>Mark</name> <age>30</age> </row> </students>');

    I don't think you really want to send the value '1', do you? (I fixed the typo at the end of that statement.)

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

      Thank you for your help! I am trying to replicate the following http post request found here

      http://xmodulo.com/2013/05/how-to-send-http-get-or-post-request-in-perl.html

      I would like to pass XML data into the database through an Oracle APEX restful service. I continue to insert a null value into the database. Here is the only anomaly I see after the script is executed:

      LPW::UserAgent::_need_proxy: Not proxied
      I am very new to Perl and web services. Thank you!

        I am trying to replicate the following http post request found here

        Well, you say that part is successfull ; sure, you posted code full of syntax errors which wouldn't run, but if your real code is inserting nulls it means it runs, which means the "post"ing part works

        What must be the problem is what you're posting, not how

        So what APEX docs are you reading that tell you what you're supposed to send?