How to call REST JSON using JSON Datacontrol REST secure service?

Hello

I use 12.2 of the ADF.

I created a datacontrol REST JSON to call a simple Web service.

Which works very well.

Then, we have added Basic for this webservice.


In order to make this work, I used the steps in the guide of the developer (http://docs.oracle.com/middleware/1221/adf/develop-data-controls/)

  • 5.2.4 How to include a header to a Web Service data control parameter
  • 5.2.5 How to include a header setting customized for a RESTful Web Service

I have the header parameter in the connection.xml

<httpHeaders paramName="Authorization" value="#{backingBeanScope.securityBean.myAuthorization}"/>

The question I have now is this:

What should be the exact value of the property of myAuthorization?

I tried the following, but it doesn't work.

public class SecurityBean {
      private String myAuthorization;
      public SecurityBean() {
         
      String username ="theUser";
      String password ="hisPassword";
         
          String myAuthorizationString = "Basic " + username+":"+password;
         
          Base64.Encoder encoder = Base64.getEncoder();
          myAuthorization = encoder.encodeToString(
                  myAuthorizationString.getBytes(StandardCharsets.UTF_8) );       
      }
   public void setMyAuthorization(String myAuthorization) {
        this.myAuthorization = myAuthorization;
    }
    public String getMyAuthorization() {
        return myAuthorization;
    }
}


Any help is appreciated.


Thank you


Luke

LKO

I messed up. Twice. Three times in fact...

(1) no need to add an entry in the connections.xml

(2) look at this code:

' String myAuthorizationString = 'Basic' + username + ":"+ password;

I've done encoding the entire string, including the ' base "..." That is why he is wrong.

Only need to encode the name part...

(3) other things wrong in interpreting the developer's guide.

Here's the code to work. Make sure you check the "Include http head" box when you create the rest service and that you provide the value in the pagedef when you create the service call:

     

Code of the bean, who reads the requestheader and transmits the authorization part to our call for service.

public class ServiceCallerBean {

    private Map httpHeadersMap = new HashMap();

    public ServiceCallerBean() {

        String autorizationHeader =
            FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderMap().get("Authorization");

       System.out.println("#################" + autorizationHeader);

        httpHeadersMap.put("Authorization", autorizationHeader);

    }

    public void setHttpHeadersMap(Map httpHeadersMap) {
        this.httpHeadersMap = httpHeadersMap;
    }

    public Map getHttpHeadersMap() {
        return httpHeadersMap;
    }

}

Works like a charm...

Thanks to the auto ;-)

Tags: Java

Similar Questions

  • How to call static pages using web.show_document on the application server

    Hi all.

    I'm using forms / reports 11 g Rel2.

    I´d like to call it a few static pages of forms using web.show_document and have the pages located on the same machine where the application server is running.

    I know it's more a problem of Oracle HTTP Server configuration, but I want to know if I can use one of the default virtual directories already defined on the installation process.

    Please recommend a virtual directory to use.

    Best regards, Luis... :))

    Sure. You can store the files anywhere you want. Of course, it is easy to create a new virtual directory. But if you want to use an existing one, the most obvious likely would be the virtual path of/forms/html that can be found here:

    INSTANCE_HOME\config\FormsComponent\forms\html

    The url to access it would look something like this:

    http://server:port/forms/HTML/myWebPage.htm

  • How to call the REST Webservices via native J2ME app.

    Hi, can someone help me how to call REST Webservices via native J2ME app. I don't want to use the HTTP request. Is there a possible way to call via AJAX, if so how? I use only the RIM and the J2ME API. Thank you, joy

    JSON is just the format fo the data returned.  So all you do is make a standard HTTP call, get the data and analyze using JSON.  OS 6.0 includes JSON, but OS 5.0 doesn't work, then you will need to get a JSON library if you want to use in the 5.0 OS.

    You might find them useful:

    http://supportforums.BlackBerry.com/T5/Java-development/JSON-library/m-p/573687

    http://supportforums.BlackBerry.com/T5/Java-development/sample-code-implementing-JSON-in-your-applic...

  • How to call a servlet from a browser

    Hello everyone,
    I hope you understand my poor English; After having solved a lot of problems by reading this forum, I have just signed up, and this is my first question

    I would like to know how to call a servlet using a URL.
    Now, I'm able to call the servlet this way http://localhost:8080/servlet/provaservlet/index.html because I put my web.xml in this way
    <url-pattern>* * *.html</url-pattern>
    Is it possible to call my servlet by using its name, for example Http://localhost: 8080/servletFolder/servlet/ServletName?

    I put the < url-pattern > element with everythings come to me, but I don't yet have my goal!

    Published by: 976935 on 14-Dec-2012 1.56
  • Help! Please, I beg you. Can I use Bell Internet Security Services offers after I installed Dreamweaver on my PC?

    I installed Dreamweaver in my PC. Dreamweaver seems to work very well. However, Dreamweaver executes automatically when I run the virus scan using the Bell Internet Security Services. How can I avoid that Dreamweaver running and control of work of the Security Services Bell Internet analysis of the virus?

    Post edited by: leslie6

    Hi leslie6,

    The question has been answered and resolved in the http://forums.adobe.com/message/5204300#5204300 thread started by you.

  • How to write a JSON file using edge

    I'm doing a simple blog system,

    I thought a JSON file would be the easyest, but if there is a better way please tell me

    I already know how read a. JSON file using $.getJSON ("filename", function (data) {});

    but I need to know if it is possible to write to the same file.

    Thanks for help.

    All writing in a file involves php or something similar.

  • How to call someone at adobe?  I just bought a product and can not use/search it!

    How to call someone at adobe?  I just bought a product and can not use/search it!

    HI Bruno.

    I see you have a subscription to creative under the enamel even cloud as with forums.

    You can download the installer for Creative Cloud from here:
    Creative cloud help | Creative cloud desktop.

    Please let us know if this helps you.

  • How to call a method defined in AppmoduleImpl using a groovy expression?

    Hi experts,

    With the help of jdev 11.1.1.5.0 - adfbc battery.

    I followed this post as the blogger says.
    How to call a method defined in AppmoduleImpl using a groovy expression?
    https://blogs.Oracle.com/ADF/entry/how_to_call_a_method

    While a button insert hit

    Suite error survey.
    java.sql.SQLException: ORA-20483: ADM-
    ORA-06512: at "RMSTD.FUNC_FIND_PLNT_DESC", line 22
    ORA-06512: at line 1
    
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:457)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
         at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:889)
         at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:476)
         at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:204)
         at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:540)
    It is my code for the function.
    CREATE OR REPLACE FUNCTION func_find_plnt_desc (
       p_bu        VARCHAR2,
       p_plnt_id   VARCHAR2,
       p_lang      NUMBER
    )
       RETURN VARCHAR2
    IS
       CURSOR cur_find_plant
       IS
          SELECT bup_name1, bup_name2
            FROM bus_unit_plants
           WHERE bup_bu = p_bu AND bup_plant_id = p_plnt_id;
    
       rec_find_plant   cur_find_plant%ROWTYPE;
    BEGIN
       OPEN cur_find_plant;
       FETCH cur_find_plant INTO rec_find_plant;
    --RAISE_APPLICATION_ERROR(-20999,P_BU||P_PLNT_ID);
       IF cur_find_plant%NOTFOUND
       THEN
    
          raise_application_error (-20483, 'ADM' || P_PLNT_ID ||'-'||P_BU);
          --NULL;
       END IF;
    
       CLOSE cur_find_plant;
    
       IF p_lang = 1 THEN
          RETURN (rec_find_plant.bup_name1);
       ELSIF p_lang = 2 THEN
          RETURN (rec_find_plant.bup_name2);
       END IF;
    END;
    /
    Reason behind:
    while hitting the insert means null from the value of the survey so error function.

    If am not hitting doesn't mean no problem. the function works correctly return description.

    can someone help me how to override?

    Published by: ADF7 on April 10, 2012 23:51

    ADF7,
    the subject of the post has nothing to do with the question (for as far as I see it).
    As you can see the error message clearly comes from the procedure pl/sql you call the application module, works of groovy appeal method.

    We cannot decide what makes your service if you pass null as a parameter. You can check the settings before you proceed to the procedure or write the procedure in how it treats null parameters.

    Timo

  • How to call oracle forms report using parameterlist for parameters

    Dear all,
    I want to know how to call oracle forms report and parameter passing between the report and the form with the list of parameters?
    can someone help me?

    What research? The forum is full of examples.

  • How to call the web service?

    Hello

    I want to know how to call the web service from my application HTML5 & javascript.

    Please help me find this detail as what I can access easily. and I want to access web services online (a method of it) I'm not concered with how background Web service takes place.

    I just want that when you call a web service method, I will return the result.

    Please try this out for a WebService call

    var xmlhttp;
    xmlhttp = new XMLHttpRequest();
    xmlhttp.open("get","your url",true);
    xmlhttp.setRequestHeader("Accept","application/json");
    xmlhttp.setRequestHeader("Content-type", "application/json");
    xmlhttp.onreadystatechange=function() {
     if (xmlhttp.readyState==4) {
      if (xmlhttp.status == 200) {
        console.log(xmlhttp.responseText);
      }
     }
    }
    xmlhttp.send();
    

    This will display the result of the invocation of webservice. The url is the application that you deploy and the type can be get/post. If xmlhttp.send (post) takes argument for the display of the data. You can call it by clicking a button in HTML.

  • UTL_HTTP to call the RESTful web services

    I tried a few days to access a REST Web service and the response is an HTML element:

    Supported media not taken type > 10.4.16 415

    > the server refuses the request because the entity of the request is in a format not supported by the resource for the requested method.

    It works from the browser (Mozilla). And there is demand:

    https://xmlhub-test.xxx.xx/xmlhubws/jersey/SubmitMessage

    POST/xmlhubws/jersey / SubmitMessage HTTP/1.1

    Host: xmlhub - test.xxx.xx

    User-Agent: Mozilla/5.0 (Windows NT 5.2; rv:12.0) Gecko/20100101 Firefox/12.0

    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

    Accept-Language:-us, en; q = 0.5

    Accept-Encoding: gzip, deflate

    Connection: keep-alive

    Referer: https://Portal-test.xxx.XX/portal/page/Portal/xxx/extranet/opma_main/xxxx/wsclient-xmlhub.html

    Cookie: JSESSIONID = JjhpJTqKsRYFGCjL3QLV2GcYMJHLvLDVlBL5hyh5FN8K2qyb10PR!-621147356! 625535808; ObSSOCookie=s47sUDozSHzJ%2FarHPqrcaD5LkcFJXEmkuTQKr51UYXa3lZPjeNHKjzaUmxYbPxLkZYaaztIqCJwodlHpo6D4jR%2FVkKhmd%2Bcc9dJg4jw9cA3Kn%2FZxiwe3RA1Fyf2A%2BFLgy6eQStLzV6C9QbOi2lersS9gZBbYEy28etCXhPgMuOavl3Xtnf%2BeMVCj4Hg2QQxZSt%2FHjkSWRh%2FyVhDevt2yUo4zpoLTZ7ZKX28um6FO8CCXUTCvSlljWSzhzmSL9SwO;     RSERVER_XMLHUB_TEST_TCP_7012 = R1894177232

    Content-Type: multipart/form-data; Boundary = - 204562724022109

    Content-Length: 2607

    -204562724022109

    Content-Disposition: form-data; name = "content"; filename = "abc - 01.xml".

    Content-Type: text/xml

    <? XML version = "1.0" encoding = "UTF-8"? >

    ETC.

    and my code is:

    -UTL_HTTP. CLOSE_PERSISTENT_CONNS (g_wsdl_url);

    Utl_http.set_response_error_check (false);

    Utl_http.set_detailed_excp_support (true);

    Utl_http.set_cookie_support (true);

    Utl_http.set_transfer_timeout (60);

    Utl_http.set_follow_redirect (3);

    Utl_http.set_persistent_conn_support (true);

    UTL_HTTP. SET_WALLET (xxxx, xxxxx);

    v_http_request: = utl_http.begin_request ("https://xmlhub-test.xxx.xx/xmlhubws/jersey/SubmitMessage ', ' POST ',' HTTP/1.1 '");

    Utl_http.set_body_charset (' v_http_request, ' UTF-8 ');

    Utl_http.set_authentication (v_http_request, xxxx, xxxxxx, "basic", false);

    UTL_HTTP.set_header(v_http_request,'Host','xmlhub-test.xxx.xx');

    UTL_HTTP.set_header(v_http_request,'User-Agent', 'Mozilla/5.0 (Windows NT 5.2;)) RV:12.0) Gecko/20100101 Firefox / 12.0 ');

    Utl_http.set_header(v_http_request,'Accept','Text/HTML,application/XHTML+XML,application/XML;q=0.9,*/*;q=0.8 ');

    UTL_HTTP.set_header(v_http_request,'Accept-Language','en-US,en;q=0.5');

    -UTL_HTTP.set_header (v_http_request, 'Accept-Encoding', 'gzip, deflate');

    Utl_http.set_header (v_http_request, 'Connection', 'keep-alive');

    -UTL_HTTP.set_header (v_http_request, 'Referer','https://portal-test.bnr.ro/portal/page/portal/BNR/extranet/opma_main/opma/wsclient-xmlhub.html');

    text/html; Charset = UTF - 8-' multipart/form-data ".

    Utl_http.set_header (v_http_request, 'Content-Type', ' multipart/Form-data');

    Utl_http.set_header (v_http_request, "Transfer-Encoding", "chunked");

    Utl_http.set_header (v_http_request, "Content-Length", l_clob_len);

    Utl_http.set_header (v_http_request, 'id', '"downloadMessage" ');

    Utl_http.write_text (v_http_request, p_xml.getStringVal ());

    ...

    What can I do? How cand I try. I tried dozens of variants (query of xml > 180 files).

    Please help me.

    Tjank you!

    Generate a model for POST UTL_HTTP, of the w.

    I suggest using the free version of SoapUI for this. Very simple. Create the new project of REST. Enter w location (URL). Generates a sample call and look at how the HTML call is formatted. You can also trigger test POST CALL using SoapUI. When it works, copy - paste this MESSAGE template for use in PL/SQL

    From what you have posted, it seems to be an error in user code. So if you can get the details of the correct POSITION, the user code should work.

  • How to call and parse the SOAP WSDL service in Swift 2.0 to Xcode 7.1

    I'm new to the SOAP and I don't know how to call SOAP Web service and parse XML. I also tried to try to Google.And all of the resources that I had was outdated. Y at - it a tutorial or examples that I can learn? Any help?

    Hello ColayHills,

    It's because SOAP is exceeded. It is based on XML and XML really nasty at that. You have other options or should you use SOAP?

  • How to call a second instance of the same VI?

    Hello

    I have a useful VI dealing with IO operations. To save some time, of what I would call the VI as a second instance do work at the same time. I created a sequence sub with the run option 'Use the new thread' and I called the Vi (a step of the sequence only). Execution time of the VI is about 20 seconds run Durin I called the subsequence and I carried on running my main sequence (parent). Since then 10 seconds to launch the subsequence (in the thread of sepatate I called the same VI as in the thought of subsequence the second instance will be created. However, instead of parallel work of the two instances of the same VI had to wait when mt subsequence end known call the VI th.

    So my question is, as in the topic: how to call a second instance of the VI even at the "same time"?

    Could you please tell me about the best approach to solve the problem?

    Any VI that you want to run in parallel must be paid also re-entrant, including screws.

  • How to call same vi for 4 times in a single vi?

    Hello.. I ve a vi named table 1 d Mult. I need to call this vi four times in another program of vi. The problem I've known is all the four outputs of vi are the same.

    My question is: how to call the same vi number many times?

    Thanks in advance

    Recursive calls in LabVIEW using VI Server

  • How to call windows dialog boxes

    Hello

    I just want to know how to call a windows dialog box, I called below the dialog using VB script and the script is the following lol = msgbox ("Your Message here", 19, "Your title here") and save it as a .vbs file, by changing the number "19" in the script to generate the different dialog box. And I think it is called by the user32.dl of windows.

    So can you please help me to call the dialog even in labview.

    Thank you & best regards

    Samuel J

    System engineer

    CAPTRONIC systems Pvt Ltd

    Bangalore, India.

    See attached VI calling MessageBoxA from user32.dll. Sorry for french labels, comments and the description...

Maybe you are looking for

  • Keyboard problem with key C on my Satellite L40

    (Sorry for the typos) Hello I had a problem with my keyboard and FN function:I installed windows XP on my L40. I also installed all the drivers from the download page. All the drivers work well, also the hotkey driver. My problem:If I want to write n

  • Software device driver has not been installed successfully. __This device cannot start (Code 10).

    I am running Windows 7 on a HP Pavilion a1600n and sometimes in the last month the CD/DVD drive stopped recognizing DVDs and CDs. It is opening and closing, and turn the disc when I put them in the drive, simply do not recognize anything beyond that.

  • How to refresh an image element displayed dynamically

    Hi allThis is Pavan,I use apex 4.2.3try to update an image dynamically, but did not,example I use the id selection list depends on the id of the image should be displayed, I used image is displayed to display the image (sql statement returned blob co

  • Mix together 2 objects that are made with the NET tool

    HelloPlease could someone give me a little advice in this regard?In the image below, you can see that I am trying to add a few stems look at the head, both the stems and the head is made with a gradient mesh.Is there a way to get the stems blend smoo

  • issue audio and video of Linked files

    When I let fall the first pro of the source files in first pro then move that either the audio or video files around them are not related, even though it says they are related when I right click? When I drag either or around, they separately move whi