Re: WebServiceContext not injected in endpoint
Hi, Can someone please share a full cxf xml where the JaxWsServerFactoryBean is configured with a PerRequestFactory. I want to migrate my xfire web service to cxf because I want to use the PerRequestFactory support. Thanks in advance. leewill wrote: As a matter of fact, it works for even 2.0.4. I tried it yesterday, this context got injected and I could get request back indirectly from it. Well, I used Spring bean for all my test. On 2/28/08 3:07 AM, Davide Gesino [EMAIL PROTECTED] wrote: Hi Dan, I have used this CXF 2.1 snapshot. apache-cxf-2.1-incubator-20080228.032802-34.zip 28-Feb-2008 04:16 24M I have tried this code, and actually the context is not injected. maybe I am doing something wrong. With the SingletonFactory it happens the same. Maybe the fault is the way I create the service. Anyway the creation policy works fine, with the PerSessionFactory I have a brand new instance created for each request I get. Here is the code: Object implementor = new GreeterImpl(); String address = http://localhost:9000/SoapContext/SoapPort;; org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.PerRequestFactory(GreeterImpl.class); org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.SingletonFactory(GreeterImpl.class); JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(factory); JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean(); factoryBean.setAddress(address); factoryBean.setServiceBean(implementor); factoryBean.setInvoker(invoker); factoryBean.create(); @javax.jws.WebService(name = Greeter, serviceName = SOAPService, portName = SoapPort, targetNamespace = http://apache.org/hello_world_soap_http;, wsdlLocation = hello_world.wsdl, endpointInterface = org.apache.hello_world_soap_http.Greeter) public class GreeterImpl implements Greeter { @Resource private WebServiceContext context; public java.lang.String greetMe(java.lang.String requestType) { LOG.info(Executing operation greetMe); System.out.println(requestType); if (context != null) { System.out.println(context properly injected); } else System.out.println(context properly is null!!); return hello my dear; } -- View this message in context: http://www.nabble.com/WebServiceContext-not-injected-in-endpoint-tp15708465p15732342.html Sent from the cxf-user mailing list archive at Nabble.com. -- View this message in context: http://www.nabble.com/WebServiceContext-not-injected-in-endpoint-tp15708465p16102008.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: WebServiceContext not injected in endpoint
I have tried the new snapshot (release 35) with different factories, and definetively now everything works fine. The pooled factory is pretty cool!!! thanks. Davide -- View this message in context: http://www.nabble.com/WebServiceContext-not-injected-in-endpoint-tp15708465p15758714.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: WebServiceContext not injected in endpoint
On Friday 29 February 2008, Davide Gesino wrote: I have tried the new snapshot (release 35) with different factories, and definetively now everything works fine. The pooled factory is pretty cool!!! Thanks for confirming that it works. :-) I've been thinking about this more and the new factories allow a lot of really cool things that couldn't be done before. With the exchange available, you could easily write a factory that pulls out some information (like maybe a url flag like ?user=1234 or a soap header or something) and actually create/fill in some state into an object. Then persist it when the invoke is done.Definitely some cool things can be done. -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: WebServiceContext not injected in endpoint
OK! As soon as I can I'll try CXF 2.1 and I'll send you a feedback! Thanks. Davide -- View this message in context: http://www.nabble.com/WebServiceContext-not-injected-in-endpoint-tp15708465p15731308.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: WebServiceContext not injected in endpoint
willem.jiang wrote: After went through the JaxWsServerFactoryBean codes, I think you need to modify the invoker factory construction argument. Here are the codes. Object implementor = new GreeterImpl(); String address = http://localhost:9000/SoapContext/SoapPort;; org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.SingletonFactory(implementor); JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(factory); JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean(); factoryBean.setAddress(address); factoryBean.setServiceBean(implementor); factoryBean.setInvoker(invoker); factoryBean.create(); Thanks Willem, actually it works! Anyway if I change factory and I use the PerSessionFactory or the PooledFactory I always have that the session context is always not injected. org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.PooledFactory(GreeterImpl.class,16); org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.PerSessionFactory(GreeterImpl.class); -- View this message in context: http://www.nabble.com/WebServiceContext-not-injected-in-endpoint-tp15708465p15735721.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: WebServiceContext not injected in endpoint
As a matter of fact, it works for even 2.0.4. I tried it yesterday, this context got injected and I could get request back indirectly from it. Well, I used Spring bean for all my test. On 2/28/08 3:07 AM, Davide Gesino [EMAIL PROTECTED] wrote: Hi Dan, I have used this CXF 2.1 snapshot. apache-cxf-2.1-incubator-20080228.032802-34.zip 28-Feb-2008 04:16 24M I have tried this code, and actually the context is not injected. maybe I am doing something wrong. With the SingletonFactory it happens the same. Maybe the fault is the way I create the service. Anyway the creation policy works fine, with the PerSessionFactory I have a brand new instance created for each request I get. Here is the code: Object implementor = new GreeterImpl(); String address = http://localhost:9000/SoapContext/SoapPort;; org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.PerRequestFactory(GreeterImpl.class); org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.SingletonFactory(GreeterImpl.class); JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(factory); JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean(); factoryBean.setAddress(address); factoryBean.setServiceBean(implementor); factoryBean.setInvoker(invoker); factoryBean.create(); @javax.jws.WebService(name = Greeter, serviceName = SOAPService, portName = SoapPort, targetNamespace = http://apache.org/hello_world_soap_http;, wsdlLocation = hello_world.wsdl, endpointInterface = org.apache.hello_world_soap_http.Greeter) public class GreeterImpl implements Greeter { @Resource private WebServiceContext context; public java.lang.String greetMe(java.lang.String requestType) { LOG.info(Executing operation greetMe); System.out.println(requestType); if (context != null) { System.out.println(context properly injected); } else System.out.println(context properly is null!!); return hello my dear; } -- View this message in context: http://www.nabble.com/WebServiceContext-not-injected-in-endpoint-tp15708465p15732342.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: WebServiceContext not injected in endpoint
Davide, How is your bus/cxf stuff configured? Are you using the defaults or are you specifically using the spring imports to import very specific things? If it's the latter, you will need to import: META-INF/cxf/cxf-extension-jaxws.xml as well. If it's the former, that sounds like a problem. I'll try digging into this a little bit Dan On Thursday 28 February 2008, Davide Gesino wrote: willem.jiang wrote: After went through the JaxWsServerFactoryBean codes, I think you need to modify the invoker factory construction argument. Here are the codes. Object implementor = new GreeterImpl(); String address = http://localhost:9000/SoapContext/SoapPort;; org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.SingletonFactory(implementor); JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(factory); JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean(); factoryBean.setAddress(address); factoryBean.setServiceBean(implementor); factoryBean.setInvoker(invoker); factoryBean.create(); Thanks Willem, actually it works! Anyway if I change factory and I use the PerSessionFactory or the PooledFactory I always have that the session context is always not injected. org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.PooledFactory(GreeterImpl.class,16); org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.PerSessionFactory(GreeterImpl.class); -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
Re: WebServiceContext not injected in endpoint
Never mind, this is definitely not working. Looking into it. Dan On Thursday 28 February 2008, Daniel Kulp wrote: Davide, How is your bus/cxf stuff configured? Are you using the defaults or are you specifically using the spring imports to import very specific things? If it's the latter, you will need to import: META-INF/cxf/cxf-extension-jaxws.xml as well. If it's the former, that sounds like a problem. I'll try digging into this a little bit Dan On Thursday 28 February 2008, Davide Gesino wrote: willem.jiang wrote: After went through the JaxWsServerFactoryBean codes, I think you need to modify the invoker factory construction argument. Here are the codes. Object implementor = new GreeterImpl(); String address = http://localhost:9000/SoapContext/SoapPort;; org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.SingletonFactory(implementor); JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(factory); JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean(); factoryBean.setAddress(address); factoryBean.setServiceBean(implementor); factoryBean.setInvoker(invoker); factoryBean.create(); Thanks Willem, actually it works! Anyway if I change factory and I use the PerSessionFactory or the PooledFactory I always have that the session context is always not injected. org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.PooledFactory(GreeterImpl.class,16); org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.PerSessionFactory(GreeterImpl.class); -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog
WebServiceContext not injected in endpoint
trying customizing the JAxWSMethodInvoker I have problems injecting the web service context with the @Resource annotation. Maybe there's something wrong in what I am doing, maybe it could be a bug. Assume you have a GreeterImpl endpoint with the web service context injected. Try the following: case 1 ScopePolicy policy = ApplicationScopePolicy.instance(); // trying with the following is the same: // ScopePolicy policy = RequestScopePolicy.instance(); org.apache.cxf.common.util.factory.Factory factory= new LocalFactory(GreeterImpl.class); JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(fattorazza, policy); JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean(); factoryBean.setAddress(address); factoryBean.setServiceBean(implementor); factoryBean.setInvoker(invoker); factoryBean.create(); case 2 Endpoint.publish(address,implementor); the endpoint public class GreeterImpl implements Greeter { @Resource private WebServiceContext context; public java.lang.String greetMe(java.lang.String requestType) { if (context != null) { // in case 1 it is null, in case 2 it is !=null } return hello + requestType; } in case 1 the method invocation works fine, but the context is not injected, while in case 2 the context is injected. where is the fault? Davide -- View this message in context: http://www.nabble.com/WebServiceContext-not-injected-in-endpoint-tp15708465p15708465.html Sent from the cxf-user mailing list archive at Nabble.com.
Re: WebServiceContext not injected in endpoint
This is one of the many issues with the ScopePolicy/factory stuff which is one of the reasons I eliminated the ScopePolicy stuff entirely from the 2.1/trunk codebase. :-) Is there any chance you could give the 2.1 snapshots a try? Configuring your usecase will be SLIGHTLY different, but not by much: org.apache.cxf.service.invoker.Factory factory = new org.apache.cxf.service.invoker.PerRequestFactory(GreeterImpl.class); JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(factory); . The newer Factory stuff, since it has access to the exchange at request time, can get the bus and thus get the resources properly injected. That said, the resource injection isn't free so that will add a small amount of extra processing per request. Thus, you might want to use the PooledFactory to maintain a pool of GreeterImpl objects or possibly a SessionFactory to create one per session (assuming your clients honor the session). In anycase, with the 2.1 code the major bugs should be fixed and I'd LOVE to see someone else test it a bit to makre sure. Basically, resources should get injected and the pooled stuff should actually work. Dan On Wednesday 27 February 2008, Davide Gesino wrote: trying customizing the JAxWSMethodInvoker I have problems injecting the web service context with the @Resource annotation. Maybe there's something wrong in what I am doing, maybe it could be a bug. Assume you have a GreeterImpl endpoint with the web service context injected. Try the following: case 1 ScopePolicy policy = ApplicationScopePolicy.instance(); // trying with the following is the same: // ScopePolicy policy = RequestScopePolicy.instance(); org.apache.cxf.common.util.factory.Factory factory= new LocalFactory(GreeterImpl.class); JAXWSMethodInvoker invoker = new JAXWSMethodInvoker(fattorazza, policy); JaxWsServerFactoryBean factoryBean = new JaxWsServerFactoryBean(); factoryBean.setAddress(address); factoryBean.setServiceBean(implementor); factoryBean.setInvoker(invoker); factoryBean.create(); case 2 Endpoint.publish(address,implementor); the endpoint public class GreeterImpl implements Greeter { @Resource private WebServiceContext context; public java.lang.String greetMe(java.lang.String requestType) { if (context != null) { // in case 1 it is null, in case 2 it is !=null } return hello + requestType; } in case 1 the method invocation works fine, but the context is not injected, while in case 2 the context is injected. where is the fault? Davide -- J. Daniel Kulp Principal Engineer, IONA [EMAIL PROTECTED] http://www.dankulp.com/blog