Getting Portal pages with utl_http (how-to)

I was so happy when I managed to fetch Portal pages using utl_http I thought I'd share my code.
The example function is supposed to be called through the browser (although probably not directlty),
logged in or not. The function will set the current cookies to support page access and/or
item level security.
My versions are
Oracle Portal Version: 9.0.2.2.22
Oracle9i Enterprise Edition Release 9.0.1.3.1 - Production
PL/SQL Release 9.0.1.3.1 - Production
CORE     9.0.1.2.0     Production
TNS for 32-bit Windows: Version 9.0.1.3.0 - Production
NLSRTL Version 9.0.1.3.0 - Production
Here's the code, hope someone has use of it:
CREATE OR REPLACE FUNCTION GetPortalPage ( psURL in varchar2 ) return varchar2 IS
arrCookies utl_http.cookie_table;
arrNames owa_cookie.vc_arr;
arrValues owa_cookie.vc_arr;
nCount integer;
req utl_http.req;
resp utl_http.resp;
data VARCHAR2(2048);
sHTML varchar2(32767);
BEGIN
utl_http.clear_cookies;
-- get the cookies set in the browser
owa_cookie.get_all(arrNames, arrValues, nCount);
for i in 1..nCount loop
arrCookies(i).name := arrNames(i);
arrCookies(i).value := arrValues(i);
arrCookies(i).domain := 'yourdomain.com';
arrCookies(i).expire := sysdate + 1;
arrCookies(i).path := '/';
arrCookies(i).secure := false;
arrCookies(i).version := 1;
arrCookies(i).comment := null;
end loop;
-- set the cookies so that utl_http uses them as well
utl_http.add_cookies( arrCookies );
req := utl_http.begin_request(psURL, 'GET');
-- without the next two lines Portal will assume you are a
-- mobile device or something :)
utl_http.set_header(req, 'Accept', 'text/plain, text/html');
utl_http.set_header(req, 'User-Agent', 'Mozilla/4.0');
resp := utl_http.get_response( req );
begin
loop
utl_http.read_text(resp, data, 2048);
sHTML := sHTML || data;
end loop;
exception
when utl_http.end_of_body then
-- this error is expected when the whole page is read
null;
end;
utl_http.end_response( resp );
return sHTML;
END GetPortalPage;

I also need to fetch Portal pages using utl_http to manipulate the html code before returning to the browser. Even after applying the tricks from the sample above I'm still unable to forward the cookies returned from the browser to the utl_http request to make it effectively part of the original Portal session the browser uses.
Below is a piece of code from a test case I've prepared, that displays cookies:
CREATE OR REPLACE package http_test is
procedure proc1;
procedure proc2;
end http_test;
CREATE OR REPLACE package body http_test is
procedure show_cookies
is
t_names owa_cookie.vc_arr;
t_vals owa_cookie.vc_arr;
n_num_vals integer;
begin
owa_cookie.get_all(t_names,t_vals,n_num_vals);
htp.p('No of cookies: '||to_char(n_num_vals)||'<br>');
for i in 1..n_num_vals loop
htp.p(t_names(i)||' = '||t_vals(i)||'<br>');
end loop;
end show_cookies;
procedure forward_cookies
is
t_names owa_cookie.vc_arr;
t_vals owa_cookie.vc_arr;
n_num_vals integer;
t_cookies utl_http.cookie_table;
r_cookie utl_http.cookie;
begin
-- Get cookies sent from browser
owa_cookie.get_all(t_names,t_vals,n_num_vals);
-- Set cookies in utl_http
for i in 1..n_num_vals loop
r_cookie.name := t_names(i);
r_cookie.value := t_vals(i);
r_cookie.domain := 'mydomain.com';
r_cookie.expire := sysdate+1;
r_cookie.path := '/';
r_cookie.secure := false;
r_cookie.version := 1;
r_cookie.comment := null;
t_cookies(i) := r_cookie;
end loop;
end forward_cookies;
procedure proc1
is
req utl_http.req;
resp utl_http.resp;
data varchar2(2048);
begin
-- 1. Show cookies available in proc1
htp.p('<br>proc1<br>'
show_cookies;
-- 2. Show cookies available in proc2 when called directly
proc2;
-- 3. Show cookies available in proc2 when called using utl_http
-- Initialize cookies
utl_http.clear_cookies;
forward_cookies;
-- Send request
req := utl_http.begin_request
( 'http://host.mydomain.com:7778/pls/portal/schema.http_test.proc2'
, 'GET'
utl_http.set_header
( req
, 'Accept'
, 'text/plain
, text/html'
utl_http.set_header
( req
, 'User-Agent'
, 'Mozilla/4.0'
-- Fetch and process response
resp := utl_http.get_response( req );
begin
loop
utl_http.read_text(resp, data, 2048);
htp.p(data);
end loop;
exception
when utl_http.end_of_body then null;
end;
utl_http.end_response( resp );
end proc1;
procedure proc2
is
begin
htp.p('<br>proc2<br>'
show_cookies;
end proc2;
end http_test;
After granting this package to portal_public I call proc1 from the browser that returns two equal cookies appropriately for proc1 and proc2 but only portal cookie with a different value that changes with every new request. Sample response below:
proc1
No of cookies: 2
NLS_LANGUAGE = fi-fi%2Bsf%2BFINLAND
portal = 9.0.3+fi-fi+sf+FINLAND+E9DC359A80286AF5E03059C0C47764CA+89C0EE8BC55BAAC80E85148AF3C2000604C0EF4DAEEB15A5F09065ADA0F7D02F1B763785A750735CDC1BF58D1CBED7A6B66FA41DF2B120A014CF9632A2E1AB06CFAB78230700A28D4ED38071B7BAC929E1CC48653949D387
proc2
No of cookies: 2
NLS_LANGUAGE = fi-fi%2Bsf%2BFINLAND
portal = 9.0.3+fi-fi+sf+FINLAND+E9DC359A80286AF5E03059C0C47764CA+89C0EE8BC55BAAC80E85148AF3C2000604C0EF4DAEEB15A5F09065ADA0F7D02F1B763785A750735CDC1BF58D1CBED7A6B66FA41DF2B120A014CF9632A2E1AB06CFAB78230700A28D4ED38071B7BAC929E1CC48653949D387
proc2
No of cookies: 1
portal = 9.0.3+en-us+us+AMERICA+E9DC752B1ED397CAE03059C0C4772C4E+A802192F1D30ABC0790DBB45D30F1FB4E8B876148D14C9AB3BC6D99EF1F72D3E51503FEEDDB9F7ED2C1A7A99C60AFD0ED81945656D3C9AF3C1A926248DA6C00D03DEF6FEB5E869C338B41AAAB0BBD64C1C490DDFD8EE2DE9
Any ideas what's wrong or other ways how Portal page html code could be fetched for manipulation before returning to the browser.

Similar Messages

  • I have a ipod and it needs to be activated, but my brother used it and he gave it back to me and moved away i cant get in contact with him how do i fix it ?

    i have a ipod and it needs to be activated, but my brother used it and he gave it back to me and moved away i cant get in contact with him how do i fix it ?

    You are running into
    Find My iPhone Activation Lock
    Can yo get your brother to do this:
    Find My iPhone Activation Lock: Removing a device from a previous owner’s account
    Are you the original purchaser and have proof of purchase? If so them Apple can help.
    Apple - Support - iTunes - Contact Us

  • When I print I get multiple pages with a little print on all pages of what I want printed

    when I print I get multiple pages with what I am printing with a few lines on each page till what I have printed is complete.
    This question was solved.
    View Solution.

    mamorse,
    Thanks for the additional info. Lets try downloading and running the Print and Scan doctor located here. It can fix a lot on its own but if not it will give us a better idea of what is going on. The weak signal is not likely the culprit (as it has been working for a good while) but we can try altering that if other steps fail.
    You can say thanks by clicking the Kudos Star in my post. If my post resolves your problem, please mark it as Accepted Solution so others can benefit too.

  • Working in muse when I go to right click I don't get the Page Properties menu how do I change ?

    Working in muse when I go to right click I don't get the Page Properties menu how do I change this ?

    Hello,
    What do you right click on? Usually you should be able to see Page Properties when you right click on a page from the plan mode, or you can also find page properties if you open the individual pages and then go to Page -> Page Properties. However, if you are in the plan mode and you try to use the Page -> Page Properties, that won't work and the "Page Properties" option would be grayed out.
    Hope this helps.
    Cheers
    Parikshit

  • Intellicast it does not load the way it did before. Now I just get a page with writing yet on Explpre it losds the right way

    I tried reinstalling Firefox but I get the same thing with Intellicast. I get a page with typed writing instead of a grafic page with the maps and 10 day forecast. I go to Internet Explorer and get the same intellicast.com page and it opens up the right way. what is the problem and can it be fixed. I never had this problem before with intellicast and have been using it for some time on firefox

    If it happens again the first try these basic steps:
    Reload web page(s) and bypass the cache to refresh possibly outdated or corrupted files.
    *Press and hold Shift and left-click the Reload button.
    *Press "Ctrl + F5" or press "Ctrl + Shift + R" (Windows,Linux)
    *Press "Command + Shift + R" (MAC)
    Clear the cache and the cookies from sites that cause problems.
    "Clear the Cache":
    *Tools > Options > Advanced > Network > Cached Web Content: "Clear Now"
    "Remove Cookies" from sites causing problems:
    *Tools > Options > Privacy > Cookies: "Show Cookies"

  • How do i open a web page with VeriSign Class 3 Extended Validation SSL SGC SS CA certfificate i can't open web pages with this, how do i open a web page with VeriSign Class 3 Extended Validation SSL SGC CA certfificate i can't open web pages with this

    how do i open a web page with VeriSign Class 3 Extended Validation SSL SGC SS CA ?

    Hi
    I am not suprised no one answered your questions, there are simply to many of them. Can I suggest you read the faq on 'how to get help quickly at - http://forums.adobe.com/thread/470404.
    Especially the section Don't which says -
    DON'T
    Don't post a series of questions in  a single post. Splitting them into separate threads increases your  chances of a quick answer.
    PZ
    www.pziecina.com

  • To create a sort of "browse the pages" in a page with DWCS6: how?

    Hello all again,
    as usual i'm here with something that for me seems impossible and maybe it's super easy... i checked online but i couldn't find any answer. I start with a description of what i want to accomplish:
    - i have 1 database (mySQL) with a table called "Books", inside i have these fields: Title (VARCHAR 60), Author (VARCHAR 20), StoryText (LONGTEXT)
    - i have 1 page for me, where i insert with a form a book when i want to update the DB
    - i have 2 PHP pages, one that has links where the user chooses, for example, the name of a book and the other that gets that name from the URL and show the content (x chapters of the story, tale or whatever)
    - i'm the user and i click on the link "The Little Prince", the page loads and shows me the title, the author, the text of x chapters (let's say 4 chapters)
    - that text has to be "divided" in more than one page because it's too long for a single page, so i want to see something like:
    Example when you enter the page:
    The Little Prince
    Once upon a time......
    Page 1 | >> | Last page
    and example when you reach page 9:
    The Little Prince
    The little prince....
    First page | << | Page 9 | >> | Last page
    All of this has to be in a single page though, no links to somewhere else or so. It's not a page itself but it appears in a PHP page like a table, textarea and so on. The closer thing i can think about it's a photogallery, where you press left and right and shows the pics but here, instead of pics, there's text. And if possible, i wouldn't want to create a table in my database everytime i insert a new book. What i'd like it's something that "splits" the text i have in a field called "StoryText" (table "Books") and let the user browse the pages. If i have, for example, a book 1000 lines long, i want to make a page every 50 lines so i get 20 pages. Those 20 pages need to get a sort of recordset navigation bar but... not about a recordset, only about a text in that page.
    Resuming, what i need is:
    - a way to split long text in x pages (like the example, 1 page every 50 lines of text)
    - add a navigation bar or some sort of control to browse those pages
    Is it possible something like that? Thanks.

    The example below shows you how to split the article into pages using [PAGEBREAK] inserted into the database but it only gives you the option of NEXT | PREVIOUS
    Split article into multiple pages
    I'm positive you can do exactly what you require - it's a matter of finding and piecing the code together. Entering [PAGEBREAK] into the database isn't very practical either. I'd be looking for an example that extracted a certain number of words.

  • I cant get the page with file edit tools bookmark etc

    i am unable to find or down load original page with file edit tools book as shown I've tried looking cant find it. what am I doing wrong?
    i

    Hit the '''Alt''' key to show the Menu bar, then open View > Toolbars and select Menu bar, so it has a check-mark.

  • UWL launchInNewWindow open every time a new portal page with header

    Dear all,
    since SPS 16 of EP7 the UWL actions open allways an new portal window with header.
    In the xml configuration there is set
    launchInNewWindow="yes" but no value ="portal" is set so why open the uwl the complete window with header.
    Does anyone know a value to set no header, i found a value
    launchInNewWindow="SHOW_HEADERLESS_PORTAL"
    but this one didn't works for normal items with transaction launcher it seems to be for webdynpros.
    The action viewDetail open a new portal window in the same way.
    Best regards
    Thorsten

    hi,
    i guess... tht could b problem with WorkBound property mode property...b'coz normally whenver an application open in new window we set workbound property to 2 from it's default value 1.
    i don't know exactly where it is, but it is somewhere in
    System Administration -->System Configuration -->Services.
    Hope this helps you!!!
    regards,
    Jigar Oza

  • How to get Portal page data in PL/SQL

    Hi,
    I have a oracle portal and i created a portlet in it. In its Pl/sql space i am writing a wrapper which calls a procedure in the database.
    I have dymaically created a html page through pl/sql.
    I am able to display the data in the form but my requriement is i have a text box in the form and i need to reteive that value in my Pl/SQL procedure to perform further operations.
    My problem is how do i retrieve a value present in the form in my Pl/Sql procedure
    Let me know for any concerns.
    Thanks
    Shubhadeep

    Perhaps, this is not a PL/SQL problem. This is your Oracle Portlet problem. You should see it's manual about the way to pass the data inside a procedure through form - i guess.
    Regards.
    Satyaki De.

  • How do i get a page with an anchor point come in underneath my header and a static slideshow at the top of my site? Thanks in advance

    HI
    Im really struggling with this!!!!
    I have my header set up and directly underneath I have a slideshow. I want to anchor my :contact me" page to come in just under the slideshow. I cant figure this out for the life ofe me.
    Any help will be greatfully received.
    Paul

    No use at all with Firefox 4. If the search box is left empty "Please fill in this field" is returned.

  • When I try to print, I get one page with a header and the background image, another page with the content, and a third page with a footer and background image. How can I make it print properly?

    Also, if I print to a .pdf, the background does not show up even if I have the checkbox checked to print background image.
    The site I'm trying to print is:
    [http://www.puertovallartatours.net/coupons-discounts.htm http://www.puertovallartatours.net/coupons-discounts.htm]

    I did not have the HP printer software for Mac OSX installed properly. Once installed the problem went away.

  • If you can't get web pages with internet sharing, do this.

    I could not find anything about this so I'm posting it for others, seeing as it took me a day to figure out!
    I set up a wired Bellsouth Ethernet Mini running 10.4 for internet sharing. I had a MacBook laptop to share the connection. The laptop worked with mail but Safari would not load web pages. It took all day but I realized that the laptop was not getting the DNS from the Mini.
    I found out the DNS numbers for Bellsouth and entered them (on the laptop) in the Airport TCP/IP box in Sys. Pref, Networking, "Show Airport" TCP/IP DNS box: 205.152.144.23. I'm told that 8.8.8.8 will also work (Google's public DNS server) but I have not tried it on the laptop but it worked with my iPhone.
    As soon as I put those numbers in there Safari sprang to life (on both laptop and iPhone) and worked great.
    I don't know why the Mini did not "share" the Bellsouth DNS address with the laptop. I hope this helps someone save a day of hair-pulling and frustration!
    Al
    www.ancins.com
    Message was edited by: al1776
    Message was edited by: al1776
    Message was edited by: al1776

    I've already done this, to no avail............

  • I've lost all my quick access icons. What do I do to get my page with personal features back?

    My husband set up all my quick access icons (I don't even remember what was there), with back arrows, facebook, google search box etc. It's all gone. How do I get it back?

    Larry!
    I feel you. I am having the excat same problem and it is super-anoying.
    I have also tried what that bot is suggesting, but I still can't add any webpages to the bookmarks toolbar.
    Have you worked out a solution by now?
    Please respond!
    -Eirik

  • When I search in "History" for items I've called up, I get a page with the heading "Library." but with no text beneath it. Thanks.

    I think it will be helpful for you to know that the History page to which I refer has beneath it such categories as Tags, All Bookmarks and Bookmarks Toolbar.
    I sometimes want to get back to an article (or whatever) that I called up earlier in the day or within the last week or more.
    Can you help? Thanks.

    I hope you see the Library List menu, and column headings, but not seeing any text doesn't sound good.
    Sidebar and Library Lists
    * History Sidebar("Ctrl+H"), History Library List("Ctrl+Shift+H")
    * Bookmarks Sidebar("Ctrl+B), Bookmarks Library List("Ctrl+Shift+B")
    Content:
    * The '''sidebars''' are automatically populated and then restricted by a search.
    * The '''Library list''' is usually empty until you make a selection History or Bookmarks on the left side panel of the Library List or enter a search. Entering a colon (":") would pick up everything avaiable in the category chosen.
    The '''search arguments''' are strings that exist in the Title or URL and can be entered in any order. The columns in the Library list can be sorted by clicking on the column heading for ascending/decending sort, or right-click on column heading (or View on menu) to add/remove columns, and columns can be dragged to change order of columns.
    The '''location bar''' uses the '''AwesomeBar''' search designed for it and can be restricted with keys to (Bookmarks, History, Tags, Title, URL, typed, Tabs) and search strings and key can be entered in any order and results appear until you hit enter. The other lists share the search strings but key does not apply because they are already specific.
    More information:
    * [http://kb.mozillazine.org/Viewing_the_browsing_history_-_Firefox#External_links Viewing the browsing history - Firefox - MozillaZine Knowledge Base] (Picture of Library list is first picture)
    * [http://kb.mozillazine.org/Sorting_and_rearranging_bookmarks_-_Firefox#Tools_for_sorting_and_viewing_bookmarks Sorting and rearranging bookmarks - Firefox - MozillaZine Knowledge Base]
    * [http://kb.mozillazine.org/Counts_-_Counting_bookmarks_history_links_and_other_data_-_Firefox Counts - Counting bookmarks history links and other data - Firefox - MozillaZine Knowledge Base]
    * [http://kb.mozillazine.org/Location_Bar_search#Location_Bar_search_.28internal_-_Auto_Complete.29 Location Bar search - MozillaZine Knowledge Base] (keys can be used to restrict the '''AwesomeBar''' search on the Location bar)

Maybe you are looking for

  • DUMP: CONNE_IMPORT_WRONG_COMP_TYPE /CX_SY_IMPORT_MISMATCH_ERROR

    Hi guru, i have this dump: Errori run-time        CONNE_IMPORT_WRONG_COMP_TYPE  Eccezione              CX_SY_IMPORT_MISMATCH_ERROR        Verific. il     18.04.2008 a  11:52:00 Error when attempting to IMPORT object "GT_YBKPF_ALV".                   

  • Caller Display ballsup

    "1. BT Privacy with Caller Display free for 12 months £1.75 This is the cost of your BT Privacy with Caller Display free for 12 months charged in advance (£1.75 a month)" Huh  Free for 12 months at a cost of £1.75/month Can BT please translate this i

  • H.264 Questions

    Hello Everyone, I was wandering if I encode a home movie via fcp via mp4 using h.264, let's say i encode the same file at 1000 kbps using only the "main" profile and then I encode the same exact file at also 1000 kbps using the "baseline" profile onl

  • Business Graphics - Download/Email

    Hello, I would like to download the graph generated using the Graphics FM to presentation server/send the graph as an email attachment. Is there any standard FM to do this. Any input is highly appreciated. Thank you.

  • What ever happened to plug and play, or simple english to explain the tech stuff.

    What ever happened to plug and play, or simple english to explain the tech stuff.