I have a web service written in Java that is slow in returning. When I say it is slow, I mean the work of the business logic is done within a few seconds but a response isn't returned to my caller for 20-30 minutes. It is much quicker when I run on a local server as opposed to a remote server. The web service runs on Tomcat 6 with Axis 2. My web service returns an array of Term objects that I created. Here is a snippet of XML that is returned...
Joined: Jul 03, 2008
This appears to be somewhat related to the Term object. When I return a String the response is much quicker. Also, when I return just one Term object, it takes longer than it should (30 seconds) but it is faster than when an array of these objects are created and returned. Any ideas on what might be wrong or how to debug?
I would use some kind of profiling software, for instance VisualVM (free and bundled with JDK 6), YourKit (rather expensive, but there is a trial license available) or TPTP (test and performance tools for Eclipse, if you are using Eclipse) also free. Alternatively I would also consider AOP.
Then profile the server when it only runs the web service that is slow, examining where it spends most of the time.
This will hopefully give you some clues to where the problem is.
Joined: Jul 03, 2008
Based on the debugging I have already done, I am certain the slowness has to do with the return value of a complex data type. The problem is not present when I return an array of Strings rather than my array of custom objects. I have not done anything special to handle the complex data type. Since this is my first time returning a complex data type from a web service, is there anything special that needs to be done? Also, I noticed that when I ask the service to create its WSDL via my web browser, it takes a bit of time to generate the WSDL. Could that be related? I did not supply a WSDL in my service archive.
Joined: Oct 04, 2006
Interesting problem, I'll give it a try, that is, write a simple web service that returns one of your custom objects.
However, first I need to ask what kind of data binding you are using (since I've heard Axis2 supports a number of different data bindings)?
Had a chance to, using the Eclipse WS wizard, generate a service that returns either one Term object or an array of Term objects.
Tested both the SOAP 1.1 and SOAP 1.2 binding using soapUI and they both return an array of 500 Term objects in a blink of an eye.
The HTTP binding seems a little more unreliable. First of all, I cannot test it from soapUI, so I used the Eclipse web service explorer to test it. Don't know if it is a problem with the web service explorer or the web service, but I cannot seem to retrieve an array of Term objects with this binding.