Home » SQL & PL/SQL » SQL & PL/SQL » Calling webservice from plsql package (merged) (Oracle12c)
Calling webservice from plsql package (merged) [message #678721] Sun, 05 January 2020 00:59 Go to next message
Shiv93
Messages: 34
Registered: September 2019
Member
Hi Everyone,

I have a requirement to call a webservice which actually returns a PDF file when I hit that webservice via swagger link with all the necessary inputs.Now when I try to hit that webservice link from my plsql package with the necessary inputs I'm not getting PDF file generated but I get the response as 200. Can someone guide me how to get the return response file stored in a PDF?.
Calling webservice from plsql package [message #678722 is a reply to message #678721] Sun, 05 January 2020 01:00 Go to previous messageGo to next message
Shiv93
Messages: 34
Registered: September 2019
Member
Hi Everyone,

I have a requirement to call a webservice which actually returns a PDF file when I hit that webservice via swagger link with all the necessary inputs.Now when I try to hit that webservice link from my plsql package with the necessary inputs I'm not getting PDF file generated but I get the response as 200. Can someone guide me how to get the return response file stored in a PDF?.
Re: Calling webservice from plsql package (merged) [message #678723 is a reply to message #678721] Sun, 05 January 2020 01:24 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
I try to hit that webservice link from my plsql package with the necessary inputs I'm not getting PDF file generated but I get the response as 200

We can't debug code we don't see, please post it.
Before, Please read How to use [code] tags and make your code easier to read.

Note that HTTP return code 200 is OK.

Re: Calling webservice from plsql package (merged) [message #678745 is a reply to message #678723] Mon, 06 January 2020 07:54 Go to previous messageGo to next message
Bill B
Messages: 1971
Registered: December 2004
Senior Member
Unless the web site is programmed to return the binary object, it will never happen. The 200 indicates that the web service accepted your connection. Also how are you accepting back the binary response? Without the code for when you call the web page we can't help you in anyway. Are you using SOAP, REST, HTML. past the code fragment where you are actually asking for and retrieving the PDF.
Re: Calling webservice from plsql package (merged) [message #678985 is a reply to message #678745] Sat, 25 January 2020 03:14 Go to previous messageGo to next message
Shiv93
Messages: 34
Registered: September 2019
Member
Hi Bill / Michael,

Thanks for the reply .. Below is my code snippet used. Please let me know how should i handle the return response from the webservice to store it as a text in my table.


l_buffer VARCHAR2(32767);
req utl_http.req;
res utl_http.resp;
l_blob blob;
l_raw raw(32767);
l_content VARCHAR2(4000); -- input parameters to my webservice
url VARCHAR2(100); -- My webservice url

BEGIN

req := utl_http.begin_request(url,'POST',' HTTP/1.1');
utl_http.set_header(req,'content-type','application/json');
utl_http.set_header(req,'accept','application/pdf');
utl_http.set_header(req,'Content-Length',length(l_content) );
utl_http.write_text(req,l_content);
res := utl_http.get_response(req);
dbms_output.put_line('response' || res.status_code );
dbms_output.put_line('response_reason' || res.reason_phrase);

dbms_lob.createtemporary(l_blob, true);

begin

utl_http.read_raw(res, l_raw);
dbms_lob.writeappend (l_blob, utl_raw.length(l_raw), l_raw);
-- dbms_output.put_line('out_response.... ' || DBMS_LOB.SUBSTR(l_blob));
SELECT NVL(MAX(ID)+1,1) INTO v_id FROM Response_data;
insert into Response_data values(v_id,l_blob);
commit;

utl_http.end_response(res);
EXCEPTION
WHEN utl_http.end_of_body THEN
utl_http.end_response(res);
WHEN UTL_HTTP.TOO_MANY_REQUESTS THEN
utl_http.end_response(res);



END;
END;

[Updated on: Sat, 25 January 2020 03:15]

Report message to a moderator

Re: Calling webservice from plsql package (merged) [message #679063 is a reply to message #678985] Fri, 31 January 2020 00:44 Go to previous message
Shiv93
Messages: 34
Registered: September 2019
Member
Adding more information the response is being sent as octet stream from the api... So will I be able to handle it in my plsql procedure...Please let me know folks..
Previous Topic: How to download a BLOB field data to local storage (merged)
Next Topic: ORA-12801: error signaled in parallel query server PXXX (merged 3)
Goto Forum:
  


Current Time: Fri Mar 29 09:04:16 CDT 2024