Using utl_http tp post a mod_plsql package which has a parameter

Hi,
I'm new to using utl_http, xml and mod_plsql.
I need to test calling a mod_plsql package which receives posted data and returns a response using utl_http.
The following works fine:
SET SERVEROUTPUT ON;
CREATE OR REPLACE PROCEDURE http_test
IS
BEGIN
HTP.p (
'<?xml version="1.0" encoding="UTF-8" ?><note><to>Fred</to><from>Smith</from><heading>Reminder</heading><body>Goodbye!</body></note>
END http_test;
CREATE OR REPLACE FUNCTION HTTP_POST
RETURN VARCHAR2
IS
req UTL_HTTP.req;
resp UTL_HTTP.resp;
v_txt VARCHAR2 (1024);
posted_data VARCHAR2 (1000)
:= '<?xml version="1.0" encoding="UTF-8" ?><note><to>Fred</to><from>Smith</from><heading>Reminder</heading><body>Hello!</body></note>';
BEGIN
wallet_is_set_here;
req :=
UTL_HTTP.begin_request (
'https://url details removed for security/http_test',
'POST',
'HTTP/1.1');
UTL_HTTP.write_text (req, posted_data);
resp := UTL_HTTP.get_response (req);
UTL_HTTP.read_text (resp, v_txt);
UTL_HTTP.end_response (resp);
RETURN v_txt;
END;
SELECT http_post FROM DUAL;
i.e. it returns the following as expected:
<?xml version="1.0" encoding="UTF-8" ?><note><to>Fred</to><from>Smith</from><heading>Reminder</heading><body>Goodbye!</body></note>
However, I want to pass a parameter to the http_test procedure so I can ultimately save the posted data to a table so I can process the contents later.
If I change the code to:
CREATE OR REPLACE PROCEDURE http_test (xmlX IN VARCHAR2)
IS
BEGIN
HTP.p (
'<?xml version="1.0" encoding="UTF-8" ?><note><to>Fred</to><from>Smith</from><heading>Reminder</heading><body>Goodbye!</body></note>
END http_test;
CREATE OR REPLACE FUNCTION HTTP_POST
RETURN VARCHAR2
IS
req UTL_HTTP.req;
resp UTL_HTTP.resp;
v_txt VARCHAR2 (1024);
posted_data VARCHAR2 (1000)
:= '<?xml version="1.0" encoding="UTF-8" ?><note><to>Fred</to><from>Smith</from><heading>Reminder</heading><body>Hello!</body></note>';
BEGIN
wallet_is_set_here;
req :=
UTL_HTTP.begin_request (
'https://url details removed for security/http_test',
'POST',
'HTTP/1.1');
UTL_HTTP.set_header (req, 'Content-Type', 'text/xml; charset=utf-8');
UTL_HTTP.set_header (req, 'Content-Length', LENGTH (posted_data));
UTL_HTTP.write_text (req, posted_data);
resp := UTL_HTTP.get_response (req);
UTL_HTTP.read_text (resp, v_txt);
UTL_HTTP.end_response (resp);
RETURN v_txt;
END;
SELECT http_post FROM DUAL;
I just get a load of html returned (some of which is below to show the kind of thing):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/x
html1/DTD/xhtml1-strict.dtd">
<html dir=LTR xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
</head>
<body>
Please could someone advise me what I am doing wrong or if it is not possible to post in this way using utl_http. I'm hoping it is just a question of finding the correct settings but can't find an example that matches what we need to do.
If I post in a browser using an html form to the procedure when it has a parameter, the response is displayed correctly in the browser and it can be saved to a database(code not included in the above). However, our requirement is to do this in the background as we will be receiving a post from an external customer to which we have to respond based on the contents of the posted data.
Many thanks for any help.

Hi,
Do you mind updating your message and using enclose the code part between two lines starting with {noformat}{noformat}
i.e.:
{noformat}{noformat}
SELECT ...
{noformat}{noformat}
Please read <a href="https://forums.oracle.com/forums/thread.jspa?threadID=2174552#9360002">How do I ask a question on the forums?</a> for more details.
Regards.
Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • I've used an external drive for time machine which has important files on it. After trying to back up my computer, it suddenly needed to be "repaired" by utilities. Now it's not being "seen" at all! How do I recover my important files off the drive?

    I've used an external drive for time machine which has important files on it. After trying to back up my computer, it suddenly needed to be "repaired" by utilities. Now it's not being "seen" at all! How do I recover my important files off the drive?

    If the external drive can be seen at all in Disk Utility, follow the instructions for repair here.

  • HT1981 I will use my 110V MacBook in the Philippines which has 220V sockets. Will the World Travel Adapter Kit help me?

    I will use my 110V MacBook in the Philippines which has 220V sockets. Will the World Travel Adapter Kit help me?

    Assuming you're in North America now, you probably won't need any sort of plug adaptor there; most sockets in the Philippines are the same as those in North America. In case you do, it doesn't contain the correct adaptor.
    Voltage conversion is handled by the MacBook without any additional components.
    (66079)

  • If I have the creative cloud package which has Photoshop, Indesign and Illustrator CS6, do I have to pay to again to get the CC 2014 version?

    If I have the creative cloud package which has Photoshop, Indesign and Illustrator CS6, do I have to pay to again to get the CC 2014 version?

    It really depends on which subscription plan you are signed up to.  Normally whichever programs are available thru your subscription are listed for you to install in the CC desktop manager application.  If you do not see certain programs listed it might be because your machine does not meet the system requirements for them... that is normally what happens with the manager.

  • I have a new logic board and fce is asking for my serial number from packaging , which has long gone- help?

    final cut express
    I have a new logic board and fce is asking for my serial number from packaging , which has long gone- help?

    Without the serial number your FCE disc is useless and nobody here can help.
    Your only chance, if you have the receipt or can prove your purchase is to contact Apple and hope they may be able to help.

  • How could Ecatt support a FM which has export parameter data type as any

    Hi,
    I have created a FM which has export parameter data type as 'Type ref to data'.
    The actual paremeter value for this export parameter is a dynamically generated internal table, which does not have a abap dictionary data type.
    Could I use the 'FUN' ecatt command to test this FM?  How could I get this reference export parameter?
    Thanks a lot in advance!

    Hi,
    Wouldn't it be enough if you define parameter in test data container as reference to table type with structure of type c(1000)  (or more/less characters depending on how much data you need to pass)?
    I'm not 100% sure if filling this table with data will work (this is reference after all) but if this is an issue than create 2 parameters: 1 of table type and second of reference type. Then inside your script before FUN use ABAP...ENDABAP to assign your table parameter to reference parameter and use second one as input for FUN command.
    I think that either first or second solution should work.
    Best regards
    Marcin Cholewczuk

  • How to call a stored procedure which has out parameter value

    my code is
    public Connection createConnection() {
                   Connection conn = null;
                        try {
                             Class.forName(DRIVER);
                             conn = DriverManager.getConnection(URL,USER,PASS);
                        } catch (ClassNotFoundException cnfe) {
                             System.err.print("Class not found");
                        } catch (SQLException sqle) {
                             System.err.print("SQLException");
                   return conn;
         public static void main(String args[]){
              StroedProcedure stp = new StroedProcedure();
              Connection con = stp.createConnection();
              try {
                   CallableStatement stproc_stmt = con.prepareCall("{call Account_Summary(?,?,?,?,?,?,?,?)}");
                   stproc_stmt.setString(1, "123456");
                   stproc_stmt.setDate(2, null);
                   stproc_stmt.setString(3, null);
                   stproc_stmt.setString(4, null);
                   stproc_stmt.setString(5, null);
                   stproc_stmt.setString(6, null);
                   stproc_stmt.setDate(7, null);
                   stproc_stmt.setDate(8, null);
                   stproc_stmt.registerOutParameter(1,Types.CHAR);
                   stproc_stmt.registerOutParameter(2,Types.DATE);
                   stproc_stmt.registerOutParameter(3,Types.CHAR);
                   stproc_stmt.registerOutParameter(4,Types.CHAR);
                   stproc_stmt.registerOutParameter(5,Types.CHAR);
                   stproc_stmt.registerOutParameter(6,Types.CHAR);
                   stproc_stmt.registerOutParameter(7,Types.DATE);
                   stproc_stmt.registerOutParameter(8,Types.DATE);
                   stproc_stmt.execute();
                   System.out.println("test "+stproc_stmt.getString(1));
                   ResultSet rs = stproc_stmt.executeQuery();
                  while (rs.next()){
                       System.out.println("result "+rs.getString("ACCPK"));
              } catch (SQLException e) {
                        e.printStackTrace();
         }And the stored procedure is
    CREATE OR REPLACE
    procedure Account_Summary (accpk in out char, incdt out date, bcur out char, bmark out char, tarTE out char, numHold out char, stDt out date, AsDt out date)
    is
    begin
    select account_pk, inception_date, base_currency, benchmark  into accpk, incdt, bcur, bmark
    from account a
    where a.Account_pk=accpk;
    select target_te, number_holdings, start_date, as_date into tarTE, numHold, StDt, AsDt
    from acc_summary asum
    where asum.account_pk=accpk;
    end Account_Summary;but it gives a exception ORA-01460: unimplemented or unreasonable conversion requested
    ORA-06512: at "REPRO.ACCOUNT_SUMMARY", line 4
    ORA-06512: at line 1
    i want to execute a stored procedure which has in , inout or out parameter
    but it can not work

    ========================
    In some contects varchar2 variable limit is 32512 characters... October 16, 2003
    Reviewer: Piotr Jarmuz from Poznan, Poland
    Interesting to note is the fact that varchar2 variables as parameters to stored
    procedures (in in/out out) may be "only" 32512 bytes long.
    I've checked this in Java and Perl. 32512 is the last value that works, for any
    bigger it throws:
    Exception in thread "main" java.sql.SQLException: ORA-01460: unimplemented or
    unreasonable conversion requested
    But in PL/SQL as you said 32767
    Regards,
    Piotr
    =================================
    This i got it from ask tom, well it make sense.... try checking your input with small numbers and strings
    Have fun

  • Can the deskjet 3940 be used with a dell inspiron mini laptop which has no cd compartment?

    Hello ?
    Really keen to purchase Deskjet but at moment only have the laptop named above to use with it.Is this possible as the set up CD does not go in it as no CD compartment ?

    Hi - Try following the steps in the doc at this link.  Once you follow the link, click on:
    Install the Driver Using Windows Update with a USB Connection (Downloadable Driver Not Available) ►
    The printer driver should already be in Win7 (I don't believe it will be any different for the mini laptop). 
    Hope that helps.
    Say Thanks by clicking the Kudos thumbs up. Please mark the post that solves your problem as an Accepted Solution so other forum users can utilize the solution.
    I am an HP employee.

  • I use MAC OSX Lion 10.7.5 which has become unstable when using Internet and Pages. Any ideas?

    When using word, pages or email the cursor jumps around all over the document placing the typed information anywhere!
    I am having to constantly rewrite emails and documents
    Even writing this question has taken three attempts.
    Any ideas what I can do to solve the problem would be really appreciated.
    Could it be a keyboard problem (mine is wi-fi)?

    please someone answer!

  • IPhoto will no longer recognize my iPhone and auto download images since updates, help, I use this non stop for online business which has been halted

    imac with latest updates / iphone 5 , worked previous to iphone recent update , had to rebuild the photo library first now it downloads nothing new when i plug in the phone to the imac

    Try this possible fix:
    Robin Johnson
    This solved my questionRe: ios update problem - 7.1 11D167 iphoto not picking up new photos
    Mar 20, 2014 7:15 AM (in response to JdinPa)
    I figured out the fix for the Mac users having this problem. I connected my iPhone to my iMac and started iTunes. A dialogue came up in iTunes, I OK'd that and then OK'd the usual "Do you trust this Mac" that comes up on my iPhone.
    Suddenly Image Capture launched itself and there were all my photos, ready to be downloaded.
    As a workaround see if Image Capture can see and download your photos to a folder on the Desktop.  They can be imported from there into iPhoto.
    OT

  • How to call function which has input parameter type??

    Hi all,
    I am facing problem while
    executing select ftest1(123) from dual;
    and i am getting error
    ORA-006553:PLS-306 : wrong number or types of arguments in call to ftest1
    and this is the code for function;
    create package body pkg1 is
    type no_array is table of NUMBER index by binary_integer;
    end pkg1;
    CREATE OR REPLACE FUNCTION ftest1(lvdriver pkg1.No_arrray)
        RETURN VARCHAR2
    IS
        lv VARCHAR2(100);
    BEGIN
        FOR i IN lvdriver.first .. lvdriver.last LOOP
            SELECT last_nm
              INTO lv
              FROM person
             WHERE person_id = lvdriver(i);
            dbms_output.put_line(lv);
        END LOOP;
        RETURN lv;
    END;
    how to pass array values to function
    i need to pass multiple values to array here it is lvdriver(1,2,3,123,4,5)??

    Example...
    create or replace type tNums as table of number;
    create or replace function ftest1(nms tNums) return number is
      vResult number := 0;
    begin
      for i in 1 .. nms.count
      loop
        vResult := vResult + nms(i);
      end loop;
      return vResult;
    end;
    SQL> select ftest1(tNums(1,2,3,4)) from dual;
    FTEST1(TNUMS(1,2,3,4))
                        10

  • Getting XML data of SSIS Package (which is located in File System) from a query

    Hi,
    We have around 200 SSIS packages deployed to File System. These pacakges are being scheduled using SQL Agent job.
    So, currently I have a list of all the packages and their respective File Path.
    Note : **They are NOT deployed to Server**.
    Now, my task is to search all the packages which has a specific connection in it.
    From the below blog, I got to know we can achieve this by querying the XML data of the SSIS Package.
    https://www.simple-talk.com/sql/ssis/-exploring-ssis-architecture-and-execution-history-through-scripting/.
    But in the above article they are getting the XML definition of the Package from msdb(as it was deployed to server).
    In my requirement, SSIS Packages are in File System. Is there any way to to get the XML definition of these packages using a query.
    Please let me know if the above requirement is not clear or if any further information is required.
    Thanks
    Raksha

    Hi Visakh & Praveen,
    Thanks for the response. 
    @Visakh: The query provided by you gives the information about all the connection strings in the package.
    @Praveen: The query in the link provided by you lists the values of all the properties of the package like MaxerrorCount, CreatorName, CreatorDate and other properties.
    I think, we may have to slightly modify this query to get the connection string values
    Praveen, nice to hear from you after a long time and that too in this forum !! :) Hope you are doing good.
    Thanks
    Raksha

  • How do I improve package loading performance in BIDS when I open a package which is imported from another place?

    [This is just for sharing information for those common asked questions collected from forums. If you have any better way or feedback, please directly reply in this thread so that community users can benefit from your answers.]
    Question:
    I have a SSIS package which has some execution problem in production environment and I need to check it and perform debugging on my local machine, however when I add the package into my SSIS project and open it in BIDS, my BIDS hangs for a long time.
    Answer:
    This issue is usually caused by the fact that your SSIS package is complex with many tasks including many connection managers. When you open the SSIS package in BIDS, by default the validation process on each task will start. Since your SSIS package is copied
    from another place, the connections may be invalid. In this case, the validation process will spend a lot of time and cause the BIDS not working during this time.
    To resolve this issue, you can do as follows:
    1.Before you add the SSIS package, select your SSIS project first, then click the SSIS menu, and change your SSIS project to Offline mode by checking "Work Offline".
    2.Add your SSIS package to the project and change each Task's DelayValidation property to True.
    3.After these steps, you can modify the connections to be valid based on your local test environment.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

    Hello Charles,
    My workmate am so happy to hear this solution I told him. Really thanks for your detail solution.
    Best regards,
    Challen Fu
    Challen Fu
    TechNet Community Support

  • How to find Explain Plan for a large querry which has multiple sub querries

    Hi All,
    I have a Package which has many procedures and one of the procedure has a cursor which is like 2000 lines. This cursor has a main select statement which again has many select statements in it.
    Now how do I do the explain plan for the main select statement?
    If it can be done easier way in toad(or SQLPLUS), please tell me...

    When your query takes too long ...

  • Can we post data 32KB using utl_http package?

    I was using utl_http package for posting http data. Now there is a change in requirement and I have to call a web service instead of normal http post. Also the amount of data to be transferred now is >32KB (previously it was only 16KB). I have to manaually create the SOAP message and post it as http requset. Is it possible to post data more than >32KB using the utl_http package?
    -Kumar
    Message was edited by:
    user586950

    did a trace route and this is what it came out with
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings\Moroni>ping 64.124.140.30:9090
    Ping request could not find host 64.124.140.30:9090. Please check the name and t
    ry again.
    C:\Documents and Settings\Moroni>tracert 64.124.140.30:9090
    Unable to resolve target system name 64.124.140.30:9090.
    C:\Documents and Settings\Moroni>tracert 64.124.140.30
    Tracing route to 64.124.140.30.mfnx.net [64.124.140.30]
    over a maximum of 30 hops:
    1 13 ms 15 ms 33 ms 73.91.188.1
    2 9 ms 11 ms 9 ms GE-2-45-ur01.troutdale.or.bverton.comcast.net [6
    8.87.218.185]
    3 * 12 ms * te-9-3-ar01.troutdale.or.bverton.comcast.net [68
    .87.216.89]
    4 39 ms 13 ms 16 ms 12.116.25.33
    5 17 ms 17 ms 18 ms tbr1011401.st6wa.ip.att.net [12.122.111.6]
    6 17 ms 15 ms 16 ms 12.122.86.41
    7 * * * Request timed out.
    8 * * * Request timed out.
    9 * * * Request timed out.
    10 * * * Request timed out.
    11 * * * Request timed out.
    12 * * * Request timed out.
    13 * * * Request timed out.
    14 * * * Request timed out.
    15 * * * Request timed out.
    16 * * * Request timed out.
    17 * * * Request timed out.
    18 * * * Request timed out.
    19 * * * Request timed out.
    20 * * * Request timed out.
    21 * *

Maybe you are looking for