Re: Lazy instantiation of Web Service Client

2008-02-13 Thread Daniel Kulp
On Tuesday 12 February 2008, rsheldon wrote:
 Thanks to everyone for their help on this. It turns out that despite
 some logging that made me think it was connecting to the web service,
 CXF actually doesn't talk to the remote server until it's first used.
 I double checked this with wireshark/ethereal.

 Thanks again,
 Richard

Actually, that will depend on how you setup the client contract.   If you 
use a wsdl, it MAY contact the server to get the wsdl and schemas at 
startup time.   You can mitigate that by keeping a copy locally and 
pointing the client creation at that instead.  If it's not wsdl based, 
yea, it has no need to contact the server till used.

-- 
J. Daniel Kulp
Principal Engineer, IONA
[EMAIL PROTECTED]
http://www.dankulp.com/blog


Re: Lazy instantiation of Web Service Client

2008-02-12 Thread Daniel Kulp

Can you just use the lazy-init=true stuff built into spring?

 bean id=accountService 
   lazy-init=true
   class=my.web.service.AccountService
   factory-bean=accountProxyFactory factory-method=create/


Dan


On Tuesday 12 February 2008, rsheldon wrote:
 I've just started using CXF with Spring. I'm only using it to create
 SOAP WS clients (code generated from WSDL using CXF maven tools).

 I'd like to be able to have the services not connect on startup, but
 wait until they are first used - ie. lazy instantiation. Can this be
 done in CXF? Here's my very simple client configuration:

 bean id=accountProxyFactory
 class=org.apache.cxf.jaxws.JaxWsProxyFactoryBean
   property name=serviceClass
 value=my.web.service.AccountService/ property name=address
 value=${account.service}/
 /bean

 bean id=accountService class=my.web.service.AccountService
   factory-bean=accountProxyFactory factory-method=create/

 I can't see any attribute I can set on JaxWsProxyFactoryBean or it's
 parent ClientProxyFactoryBean that looks like it would work. There is
 a properties property, but I can't find a reference to the valid
 properties/values I can put into this map.

 Can anyone help?? Is there an attribute or property I can set to
 prevent immediate creation of the service?

 Many thanks,
 Richard

 Thanks
 Richard



-- 
J. Daniel Kulp
Principal Engineer, IONA
[EMAIL PROTECTED]
http://www.dankulp.com/blog


Re: Lazy instantiation of Web Service Client

2008-02-12 Thread rsheldon


Thanks to everyone for their help on this. It turns out that despite some
logging that made me think it was connecting to the web service, CXF
actually doesn't talk to the remote server until it's first used. I double
checked this with wireshark/ethereal.

Thanks again,
Richard

-- 
View this message in context: 
http://www.nabble.com/Lazy-instantiation-of-Web-Service-Client-tp15427056p15446405.html
Sent from the cxf-user mailing list archive at Nabble.com.



Re: Lazy instantiation of Web Service Client

2008-02-12 Thread Ian Roberts

Ian Roberts wrote:
http://johnheintz.blogspot.com/2007/11/using-lazy-proxy-to-avoid-spring.html 



The LazyProxyFactoryBean shown in this post basically allows you to wrap 
up another Spring bean with a proxy that shows the same interface, but 
delays asking for the real bean until the first method call.  Using 
this in combination with the lazy-init=true trick above should do what 
you're after.


In fact, it turns out Spring has built-in support for exactly this using 
the AOP ProxyFactoryBean:


bean id=accountProxyFactory
  class=org.apache.cxf.jaxws.JaxWsProxyFactoryBean
  lazy-init=true
  property name=serviceClass value=my.web.service.AccountService/
  property name=address value=${account.service}/
/bean

bean id=realAccountService class=my.web.service.AccountService
  factory-bean=accountProxyFactory factory-method=create
  lazy-init=true/

bean id=accountService
  class=org.springframework.aop.framework.ProxyFactoryBean
  property name=targetSource
bean class=org.springframework.aop.target.LazyInitTargetSource
  property name=targetBeanName
idref local=realAccountService/
  /property
/bean
  /property
  property name=proxyInterfaces
value=my.web.service.AccountService /
/bean

Ian

--
Ian Roberts   | Department of Computer Science
[EMAIL PROTECTED]  | University of Sheffield, UK


Re: Lazy instantiation of Web Service Client

2008-02-12 Thread Willem Jiang

Hi Richard
Hi

For the client instantiation, it just need to create the service 
model[1] first.


If you add the wsdlLocation attribute in your SEI's WebService 
annotation or specify the wsdlLocation property for the 
JaxWsProxyFactoryBean with your service endpoint's address, the client 
will hit the service before you call the proxy's operation.


Otherwise the client will not access service endpoint the before your 
start to call the proxy's operation.


[1]http://cwiki.apache.org/CXF20DOC/cxf-architecture.html#CXFArchitecture-TheServiceModel

Willem

rsheldon wrote:

I've just started using CXF with Spring. I'm only using it to create SOAP WS
clients (code generated from WSDL using CXF maven tools). 


I'd like to be able to have the services not connect on startup, but wait
until they are first used - ie. lazy instantiation. Can this be done in CXF?
Here's my very simple client configuration:

bean id=accountProxyFactory
class=org.apache.cxf.jaxws.JaxWsProxyFactoryBean
  property name=serviceClass value=my.web.service.AccountService/
  property name=address value=${account.service}/
/bean

bean id=accountService class=my.web.service.AccountService
  factory-bean=accountProxyFactory factory-method=create/

I can't see any attribute I can set on JaxWsProxyFactoryBean or it's parent
ClientProxyFactoryBean that looks like it would work. There is a
properties property, but I can't find a reference to the valid
properties/values I can put into this map. 


Can anyone help?? Is there an attribute or property I can set to prevent
immediate creation of the service?  


Many thanks,
Richard

Thanks
Richard
  




Lazy instantiation of Web Service Client

2008-02-11 Thread rsheldon

I've just started using CXF with Spring. I'm only using it to create SOAP WS
clients (code generated from WSDL using CXF maven tools). 

I'd like to be able to have the services not connect on startup, but wait
until they are first used - ie. lazy instantiation. Can this be done in CXF?
Here's my very simple client configuration:

bean id=accountProxyFactory
class=org.apache.cxf.jaxws.JaxWsProxyFactoryBean
  property name=serviceClass value=my.web.service.AccountService/
  property name=address value=${account.service}/
/bean

bean id=accountService class=my.web.service.AccountService
  factory-bean=accountProxyFactory factory-method=create/

I can't see any attribute I can set on JaxWsProxyFactoryBean or it's parent
ClientProxyFactoryBean that looks like it would work. There is a
properties property, but I can't find a reference to the valid
properties/values I can put into this map. 

Can anyone help?? Is there an attribute or property I can set to prevent
immediate creation of the service?  

Many thanks,
Richard

Thanks
Richard
-- 
View this message in context: 
http://www.nabble.com/Lazy-instantiation-of-Web-Service-Client-tp15427056p15427056.html
Sent from the cxf-user mailing list archive at Nabble.com.