RE: Using Local Transport for JUnit Tests
I recommend stealing code from AbstractAegisTest. Since I use Aegis, I can just use that class. -Original Message- From: Liu, Jervis [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 17, 2007 10:40 PM To: cxf-user@incubator.apache.org Subject: RE: Using Local Transport for JUnit Tests Hi Chris, to use local transport, you need to manually register LocalTransportFactory with all the namespaces that might be used, for example, http://schemas.xmlsoap.org/soap/http;. An example of how this is done can be found from \trunk\rt\frontend\jaxws/src/test/java/org/apache/cxf/jaxws/AbstractJaxW sT est.java. Actually almost all unit tests under jaxws module are written with local transport, so just grab one CXF unit test then copypaste, should work. Cheers, Jervis -Original Message- From: Christopher Moesel [mailto:[EMAIL PROTECTED] Sent: 2007?7?18? 2:04 To: cxf-user@incubator.apache.org Subject: Using Local Transport for JUnit Tests Hello All, I'm trying to write some JUnit tests that can test my SOAP web services using the local transport (http://cwiki.apache.org/CXF20DOC/local-transport.html). Normally I run my services using the CXF Servlet, so doing it servlet-less is somewhat new to me. Here is what I'm doing: Using a Spring ClassPathXmlApplicationContext to load up the following CXF spring configs: - META-INF/cxf/cxf.xml - META-INF/cxf/cxf-extension-soap.xml - META-INF/cxf/cxf-extension-policy.xml and also loading up my own spring configs that contain the endpoint, like so: jaxws:endpoint id=mockWebServiceEndpoint implementor=#mockWebService wsdlLocation=mockWebService.wsdl address=local://MockWebService jaxws:features wsp:Policy mtom:OptimizedMimeSerialization wsp:Optional=true/ /wsp:Policy /jaxws:features /jaxws:endpoint But... when I load them up, I get an exception with the following message: No DestinationFactory was found for the namespace http://schemas.xmlsoap.org/soap/http. I suspect I'm missing a CXF config file that defines the DestinationFactory, I'm not setting up something right on the endpoint, or I'm just completely wrong and can't even use the local transport in this way. Could someone with a clue please help me out? ;) The full stack trace is at the bottom of this message. -Chris org.apache.cxf.service.factory.ServiceConstructionException at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java: 105) at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBea n.java:142) at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:277) at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:223) at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:175) at org.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpoint(ProviderI mpl.java:74) at javax.xml.ws.Endpoint.publish(Endpoint.java:156) at com.myco.ws.client.BaseWebServiceTest.runsOnceBeforeAllTests(BaseWebServ iceTest.java:59) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25) at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAf terRunner.java:74) at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfte rRunner.java:50) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAf terRunner.java:33) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at com.intellij.rt.junit4.Junit4TestMethodAdapter.run(Junit4TestMethodAdapt er.java:54) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90) Caused by: org.apache.cxf.BusException: No DestinationFactory was found for the namespace http://schemas.xmlsoap.org/soap/http. at org.apache.cxf.transport.DestinationFactoryManagerImpl.getDestinationFac tory(DestinationFactoryManagerImpl.java:101) at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:85) at org.apache.cxf.endpoint.ServerImpl.init(ServerImpl.java:69) at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java: 90) ... 27 more IONA Technologies PLC (registered in Ireland) Registered Number: 171387 Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
Re: Using Local Transport for JUnit Tests
Hi Christopher - If you are using maven you need to add this dependency: dependency groupIdorg.apache.cxf/groupId artifactIdcxf-rt-transports-http-jetty/artifactId version${cxf.version}/version /dependency If your not using maven just add that jar to your application classpath. On Jul 17, 2007, at 12:04 PM, Christopher Moesel wrote: Hello All, I'm trying to write some JUnit tests that can test my SOAP web services using the local transport (http://cwiki.apache.org/CXF20DOC/local-transport.html). Normally I run my services using the CXF Servlet, so doing it servlet-less is somewhat new to me. Here is what I'm doing: Using a Spring ClassPathXmlApplicationContext to load up the following CXF spring configs: - META-INF/cxf/cxf.xml - META-INF/cxf/cxf-extension-soap.xml - META-INF/cxf/cxf-extension-policy.xml and also loading up my own spring configs that contain the endpoint, like so: jaxws:endpoint id=mockWebServiceEndpoint implementor=#mockWebService wsdlLocation=mockWebService.wsdl address=local://MockWebService jaxws:features wsp:Policy mtom:OptimizedMimeSerialization wsp:Optional=true/ /wsp:Policy /jaxws:features /jaxws:endpoint But... when I load them up, I get an exception with the following message: No DestinationFactory was found for the namespace http://schemas.xmlsoap.org/soap/http. I suspect I'm missing a CXF config file that defines the DestinationFactory, I'm not setting up something right on the endpoint, or I'm just completely wrong and can't even use the local transport in this way. Could someone with a clue please help me out? ;) The full stack trace is at the bottom of this message. -Chris org.apache.cxf.service.factory.ServiceConstructionException at org.apache.cxf.frontend.ServerFactoryBean.create (ServerFactoryBean.java: 105) at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create (JaxWsServerFactoryBea n.java:142) at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:277) at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:223) at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:175) at org.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpoint (ProviderI mpl.java:74) at javax.xml.ws.Endpoint.publish(Endpoint.java:156) at com.myco.ws.client.BaseWebServiceTest.runsOnceBeforeAllTests (BaseWebServ iceTest.java:59) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.jav a:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessor Impl.java:25) at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod (BeforeAndAf terRunner.java:74) at org.junit.internal.runners.BeforeAndAfterRunner.runBefores (BeforeAndAfte rRunner.java:50) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected (BeforeAndAf terRunner.java:33) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java: 52) at com.intellij.rt.junit4.Junit4TestMethodAdapter.run (Junit4TestMethodAdapt er.java:54) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java: 40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.jav a:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessor Impl.java:25) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90) Caused by: org.apache.cxf.BusException: No DestinationFactory was found for the namespace http://schemas.xmlsoap.org/soap/http. at org.apache.cxf.transport.DestinationFactoryManagerImpl.getDestinationF ac tory(DestinationFactoryManagerImpl.java:101) at org.apache.cxf.endpoint.ServerImpl.initDestination(ServerImpl.java:85) at org.apache.cxf.endpoint.ServerImpl.init(ServerImpl.java:69) at org.apache.cxf.frontend.ServerFactoryBean.create (ServerFactoryBean.java: 90) ... 27 more Julio Arias Java Developer Roundbox Global : enterprise : technology : genius - Avenida 11 y Calle 7-9, Barrio Amón, San Jose, Costa Rica tel: 404.567.5000 ext. 2001 | cell: 11.506.849.5981 email: [EMAIL PROTECTED] | www.rbxglobal.com -
Re: Using Local Transport for JUnit Tests
Here is another way to add the LocalTransport by adding these in your spring.xml instead of including META-INF/cxf/cxf-extension-local.xml bean class=org.apache.cxf.transport.local.LocalTransportFactory lazy-init=false property name=transportIds list valuehttp://cxf.apache.org/transports/local/value valuehttp://schemas.xmlsoap.org/soap/http/value valuehttp://schemas.xmlsoap.org/wsdl/soap/http/value /list /property /bean Cheers, Willem. Willem Jiang wrote: You may need to add the -META-INF/cxf/cxf-extension-local.xml And I just searched the codes with http://schemas.xmlsoap.org/soap/http;, there are some hard code of it in the SoapBindingConfiguration. You have to register do some register of local transport factory with http://schemas.xmlsoap.org/soap/http; URI to try to use the local transport. Here is an example in the AbstractJaxWsTest class. DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class); localTransport = new LocalTransportFactory(); dfm.registerDestinationFactory(http://schemas.xmlsoap.org/soap/http;, localTransport); dfm.registerDestinationFactory(http://schemas.xmlsoap.org/wsdl/soap/http;, localTransport); dfm.registerDestinationFactory(http://cxf.apache.org/bindings/xformat;, localTransport); dfm.registerDestinationFactory(http://cxf.apache.org/transports/local;, localTransport); If you still want to do use it with the spring wiring way, I think you need to fill a JIRA for it. Willem. Christopher Moesel wrote: Hello All, I'm trying to write some JUnit tests that can test my SOAP web services using the local transport (http://cwiki.apache.org/CXF20DOC/local-transport.html). Normally I run my services using the CXF Servlet, so doing it servlet-less is somewhat new to me. Here is what I'm doing: Using a Spring ClassPathXmlApplicationContext to load up the following CXF spring configs: - META-INF/cxf/cxf.xml - META-INF/cxf/cxf-extension-soap.xml - META-INF/cxf/cxf-extension-policy.xml and also loading up my own spring configs that contain the endpoint, like so: jaxws:endpoint id=mockWebServiceEndpoint implementor=#mockWebService wsdlLocation=mockWebService.wsdl address=local://MockWebService jaxws:features wsp:Policy mtom:OptimizedMimeSerialization wsp:Optional=true/ /wsp:Policy /jaxws:features /jaxws:endpoint But... when I load them up, I get an exception with the following message: No DestinationFactory was found for the namespace http://schemas.xmlsoap.org/soap/http. I suspect I'm missing a CXF config file that defines the DestinationFactory, I'm not setting up something right on the endpoint, or I'm just completely wrong and can't even use the local transport in this way. Could someone with a clue please help me out? ;) The full stack trace is at the bottom of this message. -Chris org.apache.cxf.service.factory.ServiceConstructionException at org.apache.cxf.frontend.ServerFactoryBean.create(ServerFactoryBean.java: 105) at org.apache.cxf.jaxws.JaxWsServerFactoryBean.create(JaxWsServerFactoryBea n.java:142) at org.apache.cxf.jaxws.EndpointImpl.getServer(EndpointImpl.java:277) at org.apache.cxf.jaxws.EndpointImpl.doPublish(EndpointImpl.java:223) at org.apache.cxf.jaxws.EndpointImpl.publish(EndpointImpl.java:175) at org.apache.cxf.jaxws.spi.ProviderImpl.createAndPublishEndpoint(ProviderI mpl.java:74) at javax.xml.ws.Endpoint.publish(Endpoint.java:156) at com.myco.ws.client.BaseWebServiceTest.runsOnceBeforeAllTests(BaseWebServ iceTest.java:59) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25) at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAf terRunner.java:74) at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfte rRunner.java:50) at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAf terRunner.java:33) at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52) at com.intellij.rt.junit4.Junit4TestMethodAdapter.run(Junit4TestMethodAdapt er.java:54) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:40) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.jav a:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessor Impl.java:25) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90) Caused by: org.apache.cxf.BusException: No DestinationFactory was found for the namespace http://schemas.xmlsoap.org/soap/http. at org.apache.cxf.transport.DestinationFactoryManagerImpl.getDestinationFac