1 2 3 4 Previous Next 46 Replies Latest reply on Sep 2, 2011 4:54 PM by 865989

    Problems with OWA_COOKIE send and get

      Hi all,
      I have a problem with OWA_COOKIE-package. What I'm trying to do is to integrate Oracle eBS and an APEX app. The application resides on different databases and servers.

      I'm basing my code on this white paper:

      I have the function set up in eBS and it redirects me to my APEX login page. The next step is to pass a cookie with the user name password to the APEX app. Here the problems begins.

      My launch code in the eBS database (lots of hardcoded values just for the test):
      PROCEDURE xxapex_launch (application IN NUMBER DEFAULT 107
                             , page IN NUMBER DEFAULT 1
                             , request IN VARCHAR2 DEFAULT null
                             , item_names IN VARCHAR2 DEFAULT NULL
                             , item_values IN VARCHAR2 DEFAULT NULL) AS
        OWA_UTIL.mime_header('text/html', false);
        OWA_COOKIE.send (name => 'APEX_APPS_107',
                         value => 'daniel:development',
                         expires => sysdate + 365,
      END xxapex_launch;
      The application process in APEX that should read the cookie(on-load before header):
        c OWA_COOKIE.cookie;
        a wwv_flow_global.vc_arr2;
        c := OWA_COOKIE.get('APEX_APPS_107');
        a := htmldb_util.string_to_table(c.vals(1));
        :P160_USERNAME := a(1);
        :P160_PASSWORD := a(2);
             P_UNAME => :P160_USERNAME,
             P_PASSWORD => :P160_PASSWORD,
             P_SESSION_ID => v('APP_SESSION'),
             P_FLOW_PAGE => :APP_ID||':160');
      __END IF;
      The error I get is no-data-found when this is run:
      :P160_USERNAME := a(1);

      The c.num_vals is 0 and what I can understand OWA_COOKIE.get does not find my cookie. Is there anybody out there that can point on what I'm doing wrong?

      Regards Daniel
        • 1. Re: Problems with OWA_COOKIE send and get

          If c.num_vals is 0 you would never get to:

          :P160_USERNAME := a(1);

          You would get the no-data-found exception at:

          a := htmldb_util.string_to_table(c.vals(1));

          If the your browser is not sending the cookie with the apex f?p request then the cookie most likely doesn't have path and/or domain attributes that would allow it to be sent to server:8090/apex. Try removing path=> '/' from the owa_cookie.send call. However if the eBS app is on a different host, you might have to include a domain argument also.

          • 2. Re: Problems with OWA_COOKIE send and get
            Scott, thank you for your reply.
            I understand why I get the no-data-found error, no problem.

            I have tried to remove path=> '/' with same negative result.
            Could you clearify a little bit more about the domain parameter or point my to a location where I can read about it?

            Thank you....Daniel
            • 3. Re: Problems with OWA_COOKIE send and get
              If both hosts are in the domain .mycompany.com then in the owa_cookie.send call add domain=>'.mycompany.com' (include the leading dot).

              Also, see http://en.wikipedia.org/wiki/HTTP_cookie.

              • 4. Re: Problems with OWA_COOKIE send and get
                I added the domain parameter but I still have the same problem.

                Is'nt there any hands-on solution on sending a cookie from one server to another or sombody that have come across this problem?

                • 5. Re: Problems with OWA_COOKIE send and get
                  I'd need to see the code you use to set the cookie and the code you use to read it. Also, I'd need to know the domain and hostname in each case.

                  You know, you can examine cookie properties using browser tools after you send the cookie just to confirm your assumptions.

                  • 6. Re: Problems with OWA_COOKIE send and get
                    My bad...I missed to add domain in my OWA_UTIL.redirect_url, I just had the host name there.

                    Now I can read the cookie in my APEX app and I will continue with the solution.

                    Thank you for your sparring.

                    Regards Daniel
                    • 7. Re: Problems with OWA_COOKIE send and get
                      Back on this....

                      Is there somebody that have successfully implemented the solution described in?

                      Should I create a custom login page or use the default (that using my custom Authentication Scheme)?

                      In the white paper where it's described on how to create the application process (that reads the cookie) it says (page 5):
                      "This process should be conditional and should not be run if the login page is processing a logout request."

                      Does somebody know on how to achive this?

                      In my case my eBS is on one server and the APEX installation is on another server, I don't know if that's
                      what preventing it to work.

                      I'm trying to make a very simple proof of conecpt, my app only contain one login page (the default) and
                      one blank HTML-page. I have a database link between my APEX and EBS database (using APPS user). My
                      app works fine in a stand-alone scenario. But when I start it from EBS I get the login page (the appl.
                      process code has not fired) and if I tries to login using a username and a pwd I can se that the
                      appl. process fires and is reading the cookie correctly. The problem is that it "hangs" and it seems that
                      appl. process fires over and over again (can see that in my log table).

                      My code:
                      The Authentication Function
                      create or replace FUNCTION demo_ebiz_suite_auth
                      (p_username in VARCHAR2,
                      p_password in VARCHAR2) return BOOLEAN is
                      __return true; /* can log in with whatever */

                      Application Process - On load: Before header (page template header)
                      __c OWA_COOKIE.cookie;
                      __a wwv_flow_global.vc_arr2;
                      __demo_toLog('APEX process', '1');
                      __c := OWA_COOKIE.get('APEX_APPS_'||:APP_ID);
                      __a := htmldb_util.string_to_table(c.vals(1));

                      __:P101_USERNAME := a(1);
                      __:P101_PASSWORD := a(2);

                      __demo_toLog('APEX process', ':P101_USERNAME '||:P101_USERNAME);
                      __demo_toLog('APEX process', ':P101_PASSWORD '||:P101_PASSWORD);
                      __demo_toLog('APEX process', ':APP_ID '||:APP_ID);

                      __IF :P101_PASSWORD IS NOT NULL THEN
                      ____demo_toLog('APEX process', 'before trying to login');
                      ______P_UNAME => :P101_USERNAME,
                      ______P_PASSWORD => :P101_PASSWORD,
                      ______P_SESSION_ID => v('APP_SESSION'),
                      ______P_FLOW_PAGE => :APP_ID||':1'
                      ____demo_toLog('APEX process', 'after login');
                      __END IF;
                      __WHEN OTHERS THEN
                      ____demo_toLog('APEX process', 'Fel: '||SQLERRM);

                      Maybe I'm doing some simple misstake here but I can't see it. I need a second opinion.


                      • 8. Re: Problems with OWA_COOKIE send and get
                        I created my own login page and use that instead of the one I got when I created the application. The behavior I get now is that the code (the application process) is executing when I call my APEX app from EBS but I get a HTTP 404 Not Found. The page not from comes from wwv_flow_custom_auth_std.login.

                        I think I get this error because EBS and APEX is on different servers. Is there anyway to solve this?

                        Regards Daniel
                        • 9. Re: Problems with OWA_COOKIE send and get
                          Check the Apache error log for more details about the 404 error.

                          • 10. Re: Problems with OWA_COOKIE send and get
                            Apache log file on the apex server - does not indicate the 404:
                            xx.xx.xx.xx - APEX_PUBLIC_USER [24/Oct/2007:10:48:46 +0200] "GET /pls/apex/f?p=111:1:::::: HTTP/1.1" 302 3188
                            xx.xx.xx.xx - APEX_PUBLIC_USER [24/Oct/2007:10:48:46 +0200] "GET /pls/apex/f?p=111:1:3898200361424701::::: HTTP/1.1" 302 3391

                            Apache log file on the eBS server - does indicate the 404:
                            xx.xx.xx.xx - - [24/Oct/2007:10:48:46 +0200] "GET /pls/UTV/OracleSSWA.Execute?E=%7B!3533356F4EF2FB69D1F58DC742C90148BCF9D7A5B06075F5&P= HTTP/1.1" 302 0
                            xx.xx.xx.xx - - [24/Oct/2007:10:48:46 +0200] "GET /OA_HTML/f?p=111:1:3898200361424701::::: HTTP/1.1" 404 215

                            I think what's happening is the following:
                            1. I click the link in eBs that calls my page 1 (that's what we see in the log file above)
                            2. Then the Application Processes is run and when wwv_flow_custom_auth_std.login is executed I get the 404.
                            3. This 404 is indicated by the eBS server which I really don't can understand

                            I'm really confused here. If I look in the eBS apache log file I understand that I got the 404 because
                            http://eBS-host.domain:port//OA_HTML/f?p=111:1:3898200361424701::::: does not exists, that is on
                            my APEX server.

                            • 11. Re: Problems with OWA_COOKIE send and get

                              Looks like it's doing a relative URL redirect based on the current GET from the OA_HTML path. Not sure why but you can try this: in your process, just before the call to the login procedure, do this:

                              :FSP_AFTER_LOGIN_URL := 'http://host:port/pls/apex/f?p=111:1:' || :APP_SESSION;

                              ...or put whatever app/page is appropriate if 111:1 is not, just make it an absolute URL.

                              • 12. Re: Problems with OWA_COOKIE send and get
                                YES, it works :D

                                One last thing....
                                I need to have a condition on the app.process so it's not run on every page...cause it just runs and runs and I never get redirected eventhough everything else is correct if it's unconditional.

                                I tested to insert a row in a table after I got logged in (in the app process) and then did it conditional "NOT Exists (SQL query return no rows)":
                                select 1 from demo_log and it seems to work when I log in but it also fires when I log out the I get the infinte loop. I need a condition so it not fires on log out...

                                This works fine but then I have to handle the insert and delete in this table for every user and session , there have to be a better way...?

                                Regards Daniel
                                • 13. Re: Problems with OWA_COOKIE send and get
                                  Isn't APP_USER set to the authenticated user name only if the process completes? So if :APP_USER not in ('APEX_PUBLIC_USER', 'nobody') /* and maybe other values */ you want to run the process.

                                  • 14. Re: Problems with OWA_COOKIE send and get
                                    Scott....I don't think I follow you last comment. Can you please clarify?

                                    And....thank you again for you input.
                                    1 2 3 4 Previous Next