Search code examples
javaoracleweblogicoracle-adf

HTTP Get method is not working on WebLogic Server


My HTTP Get method is working fine locally but after deployment EAR(created ear of the application) on the WebLogic Sever it is not working.

I am calling this method on the click of a button (ActionListener)

private String httpGetMethod(String number) {
        String Result = null;
        try {
            OkHttpClient client = new OkHttpClient().newBuilder().build();
            MediaType mediaType = MediaType.parse("text/plain");
            RequestBody body = RequestBody.create(mediaType, "");
            //My API URL
            String URL ="https://apilink";
            Request request = new Request.Builder().url(URL).method("GET", null).build();
            Response response = client.newCall(request).execute();
            String InitResult = response.body().string();
            Result=InitResult;
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return Result;
    }

Solution

  • Issue solved, HTTP Get method does not work in WebLogic Server if the internet call to that API url is not allowed in the network config of the that server. We allowed in the network and that method worked in the WebLogic.