2016-08-01 22 views
0

Ich möchte Daten von Webservices von Oracle-Datenbank erhalten. Aber ich suche es leider kann ich nichts. Bitte geben Sie mir einige Hinweise. Ich möchte mit Benutzernamen und Passwort in PL/SQL-Code zugreifen. Wie kann ich es tun? Danke ..Holen Sie sich Daten mit erholsamen Webservices von Oracle PL/SQL

+1

Ich habe dies selbst nicht verwendet, sondern haben eine Lese von [Nativ Oracle XML DB Web Services] (https://docs.oracle.com/database/121/ADXDB/xdb_web_services.htm) und [Oracle Basis: Web Services und Oracle Database] (https://oracle-base.com/articles/misc/web-services-and-the-oracle-database). –

Antwort

1

Sie könnten die in UTL_HTTP package

+0

Vielen Dank für Ihren Rat. Aber eine Menge Code in there.and sehr komplex –

0

ich es lösen aussehen wollen wie code.I denken folgenden es nützlich sein wird.

declare 
    t_http_req  utl_http.req; 
    t_http_resp utl_http.resp; 
    t_request_body varchar2(30000); 
    t_respond  varchar2(30000); 
    t_start_pos integer := 1; 
    t_output  varchar2(2000); 

begin 
    /*Construct the information you want to send to the webservice. 
    Normally this would be in a xml structure. But for a REST- 
    webservice this is not mandatory. The webservice i needed to 
    call excepts plain test.*/ 
    t_request_body := 'the data you want to send to the webservice'; 

    /*Telling Oracle where the webservice can be found, what kind of request is made 
    and the version of the HTTP*/ 
    t_http_req:= utl_http.begin_request('http://urlofwebservice' 
            , 'GET' 
            , 'HTTP/1.1'); 

    /*In my case the webservice used authentication with a username an password 
    that was provided to me. You can skip this line if it's a public webservice.*/ 
    utl_http.set_authentication(t_http_req,'username','password');          

    /*Describe in the request-header what kind of data is send*/ 
    utl_http.set_header(t_http_req, 'Content-Type', 'text/xml charset=UTF-8'); 

    /*Describe in the request-header the lengt of the data*/ 
    utl_http.set_header(t_http_req, 'Content-Length', length(t_request_body)); 

    /*Put the data in de body of the request*/ 
    utl_http.write_text(t_http_req, t_request_body); 


    /*make the actual request to the webservice en catch the responce in a 
    variable*/ 
    t_http_resp:= utl_http.get_response(t_http_req); 

    /*Read the body of the response, so you can find out if the information was 
    received ok by the webservice. 
    Go to the documentation of the webservice for what kind of responce you 
    should expect. In my case it was: 
    <responce> 
    <status>ok</status> 
    </responce> 
    */ 
    utl_http.read_text(t_http_resp, t_respond); 


     dbms_output.put_line(t_respond); 


    /*Some closing?1 Releasing some memory, i think....*/ 
    utl_http.end_response(t_http_resp); 
end;