Can UTL_HTTP be used in the forms. [message #677866] |
Thu, 17 October 2019 05:39  |
 |
Shiv93
Messages: 34 Registered: September 2019
|
Member |
|
|
Hi,
I'm trying to call a webservice from oracle PL/SQL package and was able to successfully invoke the webservice. But when i try to implement the same from Oracle forms am not able to call the webservice.
The code am writing is similar to the below snippet.
create or replace
procedure publish_cinema_event
( p_room_id in varchar2
, p_party_size in number
) is
req utl_http.req;
res utl_http.resp;
url varchar2(4000) := 'http://localhost:9002/cinema';
name varchar2(4000);
buffer varchar2(4000);
content varchar2(4000) := '{"room":"'||p_room_id||'", "partySize":"'||p_party_Size||'"}';
begin
req := utl_http.begin_request(url, 'POST',' HTTP/1.1');
utl_http.set_header(req, 'user-agent', 'mozilla/4.0');
utl_http.set_header(req, 'content-type', 'application/json');
utl_http.set_header(req, 'Content-Length', length(content));
utl_http.write_text(req, content);
res := utl_http.get_response(req);
-- process the response from the HTTP call
begin
loop
utl_http.read_line(res, buffer);
dbms_output.put_line(buffer);
end loop;
utl_http.end_response(res);
exception
when utl_http.end_of_body
then
utl_http.end_response(res);
end;
end publish_cinema_event;
This works fine when im writing this piece of code as a PL/SQL package but im having issues with oracle forms because i dont think the UTL_HTTP command is being recogonized in the oracle forms. Any members have witnessed such issue ? If so it would be great if you can share your insights.
Regards,
Siva
[Updated on: Thu, 17 October 2019 05:42] Report message to a moderator
|
|
|
|
|
Re: Can UTL_HTTP be used in the forms. [message #677876 is a reply to message #677871] |
Fri, 18 October 2019 15:47   |
 |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Forms is just another tool to access an Oracle database.
Its PL/SQL engine doesn't (or, should I say, didn't) recognize some features available in database's PL/SQL engine (such as analytical functions), but - UTL_HTTP is a database package. If it works in SQL*Plus, it *should* work in Forms as well.
If you granted execute privileges on it to user that runs that form, I presume that it would work.
You say that you have problems, but never told us which problems, exactly. Any error? If so, which one? Please, share ORA-xxxxx or FRM-xxxxx codes. Also, run the form in debug mode so that you could follow its execution and pinpoint the line which causes trouble.
|
|
|
|
Re: Can UTL_HTTP be used in the forms. [message #677878 is a reply to message #677877] |
Sat, 19 October 2019 01:05   |
 |
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Granting any privilege (to yourself, eh?) within Forms doesn't make sense.
You don't need that, if user you're connected to in Forms is the same user that has already been granted that privilege.
For example, suppose there are two users in your database: Scott and Mike. Connected as SYS, you did this:
grant execute on utl_http to scott;
Then, if you connected as Scott (e.g. sqlplus scott/tiger), you were able to use UTL_HTTP. On the other hand, if you connected as Mike (sqlplus mike/lion), Mike can't use it as it wasn't granted the privilege.
The same goes for Forms: if you connected as Scott, UTL_HTTP is available to you. Otherwise, if you connected as Mike, it is not which means that if Mike is going to develop that form, it has to acquire execute privilege on UTL_HTTP first - through SQL*Plus (or whichever tool you use), not Forms itself.
|
|
|
|
Re: Can UTL_HTTP be used in the forms. [message #677895 is a reply to message #677879] |
Mon, 21 October 2019 04:17  |
cookiemonster
Messages: 13965 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
You still haven't told us what forms is doing - are you getting an error? is it hanging?
And you can't compile forms without being connected to the DB as far as I'm aware, the process needs a connection.
|
|
|