Forum Discussion

Abderrazzek's avatar
Abderrazzek
Occasional Contributor
14 years ago

Java client: 500 ms delay between requests submit operations

I have a Java Client which sends many WsdlRequest frequently and sequentially, the same WsdlRequest object is used for all the requests, i just update the request parameters in the WsldRequest object and than i send the request without reimporting the WSDL (without creating a new WsdlProject).
My problem is that the first request submit operation (request.sbumit(wsdl,false) ) takes less than 100 ms but all the next request takes between 510 and 520 ms ! which is too expensive .
the most amazing thing is that where i recreate the WsdlProject (so re-import the wsdl) and the WsdlRequest object, the following requests submit operation takes between 10 and 20 ms which gave me sens that there is a delay of 500 ms somewhere in the submit operation if i reuse the same WsdlRequest object but i couldn't find it until now.

Please any idea about the subject will be welcome.

6 Replies

  • Hi,

    thanks for this observation... could you share the actual code you are using (so we can try to get the same results) ? Which soapUI version are you using?

    regards,

    /Ole
    SmartBear Software
  • Abderrazzek's avatar
    Abderrazzek
    Occasional Contributor
    Hi,
    First of all thank you very much for your quick reply.
    I can't put all the code because there is many dependent utilities and application's classes and interfaces (more than 10) but
    this is the core section of the code:

    --------------------------------------------------------------------------------------------------------------------------------
    Method that runs the web service request and returns a notification result object which encapsulates the response
    --------------------------------------------------------------------------------------------------------------------------------
    The problem is in the submit operation in this method, which takes about 100 ms in the first call, then between 500 and 520 ms in all the next calls when i reuse the same WsdlRequest object.
    But if i recreate the WsdlProject object (re-import the WSDL ) and so the Wdlrequest object every time, the submit operation takes about 100 ms in the first call and about 20 ms in the following calls although i reload the WSDL which seems to be cached somewhere after the first call and not really entirely reloaded.
    I think that there is a configuration delay parameter (in the project level or request level) whose value is 500 ms which is applied where the same WsdlRequest object is reused and in order to solve the problem this parameter must be reset every time the request object is reused.

    * Run the web service configured to notify the application about the
    * notification.
    *
    * @param serviceConfiguration
    * the service configuration (wsdl url, operationName, user,
    * password)
    *
    * @return the notification result
    */
    private NotificationResult runWebService(
    ServiceConfigurationModel serviceConfiguration) {
    NotificationResult result = null;
    try {
    String operationName = serviceConfiguration.getOperationName();
    String wsdlUrl=serviceConfiguration.getWsdlUrl();
    //Looking for the request object into the request map
    WsdlRequest soapuiWsdlRequest = requestsMap.get(operationName);
    if (soapuiWsdlRequest == null) {
    //If the request object for the operation 'operationName' not found in the map
    //create the request
    soapuiWsdlRequest = getSoapuiWsdlRequest(operationName,wsdlUrl);
    //put the request into the map for eventual next use
    //we suppose that an 'operationName' can not be exposed by more than a wsdlUrl
    requestsMap.put(operationName,soapuiWsdlRequest);
    }
    //Preparing the service operation arguments
    ArrayList<Parameter> serviceArguments = NotificationDataModel
    .getInstance().LoadServiceData(serviceConfiguration);
    // Fetching service operation parameters into the request object
    if (serviceArguments != null && soapuiWsdlRequest != null) {
    for (Parameter parameter : serviceArguments) {
    setRequestPropertyValue(soapuiWsdlRequest, parameter);
    }
    WsdlSubmitContext wsdl = new WsdlSubmitContext(
    soapuiWsdlRequest.getParent());
    long startSubmit = System.currentTimeMillis();
    // The submit operation where the problem occurs: it takes 100
    // ms on the first call, than between 500 and 520 ms in all the
    // next calls
    Submit submit = soapuiWsdlRequest.submit(wsdl, false);
    long endSubmit = System.currentTimeMillis();
    WSLogger.info("WS Response waiting has taken "
    + (endSubmit - startSubmit) + " ms.");
    result = getNotifcationResult(submit, serviceConfiguration);
    }
    } catch (Exception e) {
    e.printStackTrace();
    WSLogger.error("Error occured during ws request execution :"
    + e.getMessage());
    result = new NotificationResult();
    result.setError(e.getMessage());
    result.setStatus(NotificationStatus.ERROR);
    }
    return result;
    }

    --------------------------------------------------------------------------------------------------------------------------------
    Method that creates a new soapui WsdlProject object using the wsdl url
    --------------------------------------------------------------------------------------------------------------------------------

    /**
    * Creates the wsdl project.
    *
    * @param wsdlUrl
    * the service name
    *
    * @return the wsdl project
    */
    private WsdlProject createSoapuiWsdlProject(String wsdlUrl) {

    WsdlProject soapuiWsdlProject = null;
    if (StringUtils.isNotEmpty(wsdlUrl)) {
    try {
    soapuiWsdlProject = new WsdlProject();
    } catch (Exception e) {
    WSLogger.error("Error occured during creating a WsdlProject instace.");
    e.printStackTrace();
    return null;
    }
    WSLogger.info("Start WSDL import ...");
    try {
    long startImport = System.currentTimeMillis();
    WsdlInterfaceFactory.importWsdl(soapuiWsdlProject, wsdlUrl,
    true);
    long endImport = System.currentTimeMillis();
    WSLogger.info("WSDL import finished.");
    System.out.println("WSDL Import has taken = "
    + (endImport - startImport) + " ms");

    } catch (SoapUIException soapException) {
    WSLogger.error("SoapUIException occured during importing Wsdl "
    + wsdlUrl);
    soapException.getStackTrace();
    }
    }
    return soapuiWsdlProject;
    }

    --------------------------------------------------------------------------------------------------------------------------------
    Method that gets a WsdlRequest object using the wsdl url and the operation name
    --------------------------------------------------------------------------------------------------------------------------------

    /**
    * Gets the wsdl request for service.
    *
    * @param operationName
    * the service name
    * @param wsdlUrl
    * the wsdl url
    *
    * @return the wsdl request for service
    * @throws Exception
    */
    private WsdlRequest getSoapuiWsdlRequest(String operationName,String wsdlUrl)
    throws Exception {
    WsdlRequest soapuiWsdlRequest = null;
    try {
    WsdlProject soapuiWsdlProject = createSoapuiWsdlProject(wsdlUrl);
    if (soapuiWsdlProject == null)
    return null;
    String[] splittedWsdlUrl = wsdlUrl.split(":");
    if (splittedWsdlUrl.length >= 3) {
    String wsServerName = splittedWsdlUrl[1].substring(2,
    splittedWsdlUrl[1].length());
    String wsServerPort = splittedWsdlUrl[2].substring(0, 4);
    for (Interface wsInterface : soapuiWsdlProject.getInterfaces().values()) {
    if (wsInterface.getOperationByName(operationName) != null) {
    soapuiWsdlRequest = (WsdlRequest) wsInterface
    .getOperationByName(operationName)
    .getRequestList().get(0);
    soapuiWsdlRequest.getSettings().setString(
    HttpSettings.REQUEST_COMPRESSION, "None");
    soapuiWsdlRequest.getSettings().setString(
    HttpSettings.HTTP_VERSION,
    HttpSettings.HTTP_VERSION_1_1);
    soapuiWsdlRequest.getSettings().setString(
    HttpSettings.MAX_CONNECTIONS_PER_HOST, "500");
    setWsdlRequestEndpoint(soapuiWsdlRequest, wsServerName,
    wsServerPort);
    break;
    }
    }
    }
    if (soapuiWsdlRequest == null) {
    throw new OperationNotFoundException(operationName);
    }
    if (StringUtils.isNotEmpty(soapConnection.getUser())
    && StringUtils.isNotEmpty(soapConnection.getPassword())) {
    setAuthenticationHeader(soapuiWsdlRequest, soapConnection.getUser(),
    soapConnection.getPassword());
    }
    requestsMap.put(operationName, soapuiWsdlRequest);
    } catch (Exception e) {
    throw e;
    }
    return soapuiWsdlRequest;
    }


    Abderrazzek.
  • Abderrazzek's avatar
    Abderrazzek
    Occasional Contributor
    Hi,
    I forgot to mention that I'm using the version 4.0.0 of soapui.
  • Abderrazzek's avatar
    Abderrazzek
    Occasional Contributor
    The problem is considered as solved for me because it is reproducible only under MS Windows but not Linux System.
    But it still an astonishing behavior.
  • Abderrazzek wrote:
    Hi,
    I forgot to mention that I'm using the version 4.0.0 of soapui.

    this is a very good version what do you thing.