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.