On Mon December 14 2009 6:02:54 am Per Otto Bergum Christensen wrote:
> The runtime cost of <jaxws:client id=".. ." serviceClass=". ..PortType"
> address=".."/> is big, i takes severarl seconds. With a lot og WS
> 
> Does anyone know how du reduce this/generate classes runtime to avoid
> generating classes runtime?

Really, there isn't much that can be done here.   Almost the entire client 
startup cost is in two things:

1) JAXBContext creation:  if you have large schemas with lots of JAXB objects 
that have lots of annotations, this definitely takes a while.   While looking 
at the jaxb code last week, I discovered a system property of:
com.sun.xml.bind.v2.runtime.JAXBContextImpl.fastBoot
that if set to true supposedly enables some delaying of stuff according to 
comments, but I really don't know what it does.     Never tried it.   In 
anycase, the JAXBContext stuff is quite expensive.     We DO cache these to 
some extent so multiple clients that would use the same context don't recreate 
these.     You COULD, via spring, create a JAXBDataBinding that has a pre-
setup context that the clients use.   It would still be slow to be created, 
but it would be part of the spring setup, not client creation.  (just moves it 
around a bit)

2) WSDL/XSD parsing/processing - by default, we need to parse and process the 
wsdl/schema.   With large wsdl/xsd's with imports and such, this is semi-
expensive.   You CAN pass null as the wsdl location when creating the client 
and then set the ENDPOINT_ADDRESS_URL in the request context and this can be 
skipped (most of the time this works, but not always).     

The above 2 things account for about 85% of the client creation time, if not 
more.    The suggestion would be to do it once at application startup and then 
re-use the same client object.   See: 
http://cxf.apache.org/faq.html
about the thread safety consequences of doing so.


-- 
Daniel Kulp
[email protected]
http://www.dankulp.com/blog

Reply via email to