Hi Marc,
I believe you can do it similar in CXF.
For client side, you can do it like
       ClassPathXmlApplicationContext context
= new ClassPathXmlApplicationContext(new String[] {"demo/spring/client/client-beans.xml"});

       HelloWorld client = (HelloWorld)context.getBean("client");
Client context looks like
     <beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:jaxws="http://cxf.apache.org/jaxws";
       xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
   http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd";>

   <bean id="client" class="demo.spring.HelloWorld"
     factory-bean="clientFactory" factory-method="create"/>

<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
         <property name="serviceClass" value="demo.spring.HelloWorld"/>
<property name="address" value="http://localhost:9002/HelloWorld"/>
       </bean>

</beans>


For server side, you can do as
       org.mortbay.jetty.Server server = new org.mortbay.jetty.Server();

       SelectChannelConnector connector = new SelectChannelConnector();
       connector.setPort(9002);
       server.setConnectors(new Connector[] {connector});

       WebAppContext webappcontext = new WebAppContext();
       webappcontext.setContextPath("/");

       webappcontext.setWar("webapp");

       HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});

       server.setHandler(handlers);
       server.start();

Server context looks like
<beans xmlns="http://www.springframework.org/schema/beans";
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
       xmlns:jaxws="http://cxf.apache.org/jaxws";
       xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
   http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd";>

       <import resource="classpath:META-INF/cxf/cxf.xml" />
       <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
       <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

       <jaxws:endpoint
         id="helloWorld"
         implementor="demo.spring.HelloWorldImpl"
         address="/HelloWorld" />

</beans>
Actually, you can find more details in the spring_http sample.

Best Regards

Freeman

Marc Baumgartner wrote:
Hi Freeman,

thank you for your response. I want to do something like this with xfire:

@BeforeTest
public void beforeTest(){

        serverFactory = new 
org.springframework.context.support.ClassPathXmlApplicationContext(
                                "classpath:" + SERVER_CONTEXT);

        clientFactory = new XmlBeanFactory(
                        new ClassPathResource(CLIENT_CONTEXT));

        // Start the WebServer
        httpServer = new XFireHttpServer();
        httpServer.setPort(PORT);
        httpServer.start();
        
        XFire xfire = XFireFactory.newInstance().getXFire();
                
        AnnotationServiceFactory osf = new AnnotationServiceFactory(new 
Jsr181WebAnnotations(), xfire.getTransportManager());

        // Stelle den Service an Hand des Interfaces bereit
        Service service = osf.create(HelloWorldService.class);
        service.setInvoker(new BeanInvoker(serverFactory
                        .getBean("HelloWorldServiceBean")));

        // Register the service
        xfire.getServiceRegistry().register(service);
// Map the URL Parameter configClientFactory(clientFactory);
        serviceClient = (HelloWorldService) clientFactory
                                .getBean("HelloWorldServiceClient");

        }

        @Test
        public void testGetGreeting() {
                serviceClient.getGreeting("Marc");

        }

My client context looks like this:

<bean id="ServiceClient" 
class="org.codehaus.xfire.spring.remoting.XFireClientFactoryBean">
        <property name="serviceClass" value="hello.HelloWorldService" />
        <property name="wsdlDocumentUrl">
                <value>${url}?wsdl</value>
        </property>
        <property name="url" value="${url}" />                
</bean>

And this is from my application context service side:


        <bean id="webAnnotations" 
class="org.codehaus.xfire.annotations.jsr181.Jsr181WebAnnotations" />

        <bean id="handlerMapping" 
class="org.codehaus.xfire.spring.remoting.Jsr181HandlerMapping">
                <property name="typeMappingRegistry">
                        <ref bean="xfire.typeMappingRegistry" />
                </property>
                <property name="xfire">
                        <ref bean="xfire" />
                </property>
                <property name="webAnnotations">
                        <ref bean="webAnnotations" />
                </property>
        </bean>

        <bean 
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
                <property name="urlMap">
                        <map>
                                <entry key="/">
                                        <ref bean="handlerMapping" />
                                </entry>
                        </map>
                </property>
        </bean>

Thanks,
Marc

-------- Original-Nachricht --------
Datum: Fri, 13 Jul 2007 14:47:33 +0800
Von: Freeman Fang <[EMAIL PROTECTED]>
An: [email protected]
Betreff: Re: http://schemas.xmlsoap.org/soap/http

Hi Marc,

For setup the CXF servlet in a junit test, you can get more details from
trunk/systests/src/test/java/org/apache/cxf/systest/servlet/SpringServletTest.java
and it's superclass
trunk/systests/src/test/java/org/apache/cxf/systest/servlet/AbstractServletTest.java

Best Regards

Freeman

Marc Baumgartner wrote:
Hm, I have the Jetty Module (cxf-rt-transports-http-jetty) in my
classpath and it doesn't work.
How can I set up the CXF Servlet in a JUnit Test? I want to set up a web
service in a "before test" method, test my service and shut the web
service down.
Marc


-------- Original-Nachricht --------
Datum: Thu, 12 Jul 2007 11:00:15 -0600
Von: "Dan Diephouse" <[EMAIL PROTECTED]>
An: [email protected]
Betreff: Re: http://schemas.xmlsoap.org/soap/http

This typically happens if you're trying to create an HTTP webservice
and
haven't either:
a) Included the Jetty module on your classpath
OR
b) set up the CXFServlet.

Have you done either of those? What does your config look like?
Thanks,
- Dan

On 7/12/07, Marc Baumgartner <[EMAIL PROTECTED]> wrote:
Hi all,

I get an org.springframework.beans.factory.BeanCreationException:
Error
creating bean with name 'helloWorldWS': Invocation of init method
failed;
nested exception is java.lang.RuntimeException: Could not find
destination
factory for transport http://schemas.xmlsoap.org/soap/http

Where can I find this schema? How do I have to include it in my spring
conf?

Regards,
Marc
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog

Reply via email to