I generated a web service client using JAXWS. I notice that when using a JAXWS client, instantiating the Service
and *PortType
classes takes a while. As such, instantiating the Service
and *PortType
classes each time a request needs to be made is not a good idea.
- Is it safe to make the
Service
and*PortType
classes global to the whole web application? What are its pros and cons? - Won't there be a possibility for the request/ response to get switched to a different request/ response?
- When you call a method in a Service, does it create a new connection? Or does it simply reuse an old connection?
- If it's just reusing an old connection, then there could be some threading issue right?
Also given the code, port.calculate(requestParam)
where port is a global variable, what will happen if many threads simultaneuosly called the calculate()
method? Will each thread create a new thread for each calculate calls? Or will it wait for each calls to finish before proceeding to the next call? How will the calls be handled? I'm just afraid that I might mix some of the requests and responses.
Thanks in advanced!