Problem While Setting a Timeout from a JRF WebService in a WebCenter Portal Framework Application (Doc ID 2017726.1)

Last updated on JUNE 10, 2015

Applies to:

Oracle WebCenter Portal - Version 11.1.1.6.0 and later
Information in this document applies to any platform.

Symptoms

Experiencing problems while setting a timeout using a WebService Proxy Client inside a WebCenter Portal Framework application.

In summary, what happens is that you attempt to set a timeout for the WebService client call and such seems not to take effect.
You can simply verify this, by setting some code around the WebService call, like:

      startTime = System.currentTimeMillis();
      invoke.getWeatherServiceInstance();
      endTime = System.currentTimeMillis();
      System.out.println("That has taken " + (endTime - startTime) + " milliseconds");

The time measured will be higher then what you've set.

 

Within the custom code to set the timeout for the WebService call you should have something like the following:

    public static IServiceWeather getWeatherServiceInstance() {
        if(weatherService == null) {
            try {
                Context ctx = ADFContext.getCurrent().getConnectionsContext();
                WebServiceConnection wsc = (WebServiceConnection)ctx.lookup("weather");
                weatherService = wsc.getJaxWSPort(IServiceWeather.class);
                Map<String, Object> requestContext = ((BindingProvider)weatherService).getRequestContext();
                
                // WS Connection Timeout
                // ---------------------
                // Specifies, in seconds, how long a client application that is attempting to invoke a Web
                // service waits to make a connection. After the specified time elapses, if a connection
                // hasn't been made, the attempt times out.
                requestContext.put(BindingProviderProperties.CONNECT_TIMEOUT, 500);

                // WS Request Timeout
                // ------------------
                // Specifies, in seconds, how long a client application waits for a response from a Web
                // service it is invoking. After the specified time elapses, if a response hasn't arrived,
                // the client times out.
                requestContext.put(BindingProviderProperties.REQUEST_TIMEOUT, 5000);

            } catch (Exception e) {
                log.log(Level.SEVERE, e.getMessage(), e.getCause());
            }
        }
        return weatherService;
    }

Changes

In a simple JDeveloper Generic application and not using JFR webservices, the functionality works as expected.

 

USEFUL:

Do remember a couple of things:

  1. The timeout setting won't be really the timeout for the entire WebService client call ( request from the client + connection to the WebService + execution of the WebService + response to the client );
  2. You'll be only able to set the connection or the request/execution timeout of the WebService, not the overall timeout of the WebService client call itself.

A possible way out for this could be to use a Thread class (eg, extend it) and use a thread to invoke the WebService client and later after X time, kill it.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms