0 Replies Latest reply: Apr 11, 2014 7:39 AM by KTM RSS

    How to Consume RESTfull webservice created in Oracle Database Cloud service?

    KTM

      Hi All,

       

      I am trying to consume sample REST full web service from Oracle Database Cloud(oracle.example.hr     and URI template:  employees/{id}    ) service locally as follows

       

      public class OracleCloudClientMain {

          public OracleCloudClientMain() {

              super();

          }

        

          public static void main(String[] args){

              getJSON();

            

          }

          private static void getJSON(){

              ClientConfig config = new DefaultClientConfig();

              Client client = Client.create(config);

             

          

              WebResource service = client.resource(getBaseURI());

              System.out.println(service.path("/7839").path("JSON").accept(MediaType.APPLICATION_JSON).get(String.class));

              System.out.println(service);

          }

        

          private static URI getBaseURI(){

              return UriBuilder.fromUri("https://trial56313.db.us1.oraclecloudapps.com/apex/hr/employees/").build();

            

          }

        

        

        

        

      }

       

       

      but facing certificate exception

       

      Exception in thread "main" com.sun.jersey.api.client.ClientHandlerException: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No name matching trial56313.db.us1.oraclecloudapps.com found

        at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:128)

        at com.sun.jersey.api.client.Client.handle(Client.java:457)

        at com.sun.jersey.api.client.WebResource.handle(WebResource.java:557)

        at com.sun.jersey.api.client.WebResource.access$300(WebResource.java:69)

        at com.sun.jersey.api.client.WebResource$Builder.get(WebResource.java:451)

        at com.kbace.initiatives.OracleCloudClientMain.getJSON(OracleCloudClientMain.java:26)

        at com.kbace.initiatives.OracleCloudClientMain.main(OracleCloudClientMain.java:19)

      Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No name matching trial56313.db.us1.oraclecloudapps.com found

        at com.sun.net.ssl.internal.ssl.Alerts.getSSLException(Alerts.java:174)

        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1649)

        at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:241)

        at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Handshaker.java:235)

        at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1206)

        at com.sun.net.ssl.internal.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:136)

        at com.sun.net.ssl.internal.ssl.Handshaker.processLoop(Handshaker.java:593)

        at com.sun.net.ssl.internal.ssl.Handshaker.process_record(Handshaker.java:529)

        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:893)

        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1138)

        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1165)

        at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1149)

        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:434)

        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:166)

        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1172)

        at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:379)

        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:318)

        at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(URLConnectionClientHandler.java:215)

        at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(URLConnectionClientHandler.java:126)

        ... 6 more

      Caused by: java.security.cert.CertificateException: No name matching trial56313.db.us1.oraclecloudapps.com found

        at sun.security.util.HostnameChecker.matchDNS(HostnameChecker.java:210)

        at sun.security.util.HostnameChecker.match(HostnameChecker.java:77)

        at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkIdentity(X509TrustManagerImpl.java:264)

        at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:250)

        at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1185)

        ... 20 more

       

       

      so is there any one know how to import certificate for Oracle Database Cloud service?

      I actually tried what is mentioned in this link   https://weblogs.java.net/blog/bleonard/archive/2013/05/02/calling-oracle-cloud-service-java

       

      but i we dont have  certificate information with respect to Oracle Database cloud.

       

      Please suggest us how to consume REST Web service locally using Jdeveloper?

       

      Thanks

      Kotresh