You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by ojs <ol...@siegmar.net> on 2007/11/19 19:52:50 UTC

How to export non-annotated service in spring

Hello,

I'm trying to switch from xfire to cxf - don't had much luck so far...

My xfire configuration (in spring) looks like:

<bean name="/myService"
class="org.codehaus.xfire.spring.remoting.XFireExporter">
    <property name="serviceInterface" value="myBean"/>
    <property name="serviceBean" ref="myBeanImpl"/>
    <property name="xfire" ref="xfire"/>
</bean>

So Spring's DispatcherServlet handles the request and forward request to
/myService to this bean. The service I'm exporting isn't (and shouldn't be)
annotated. Is there a similar thing in cxf to export a service as it is
possible with xfire?


Best

Oliver
-- 
View this message in context: http://www.nabble.com/How-to-export-non-annotated-service-in-spring-tf4838545.html#a13842667
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to export non-annotated service in spring

Posted by Jeff Yu <je...@iona.com>.
You will have 2 filters, one for spring mvc, the other for the 
webservices that you want to expose: like :

  <servlet>
     <servlet-name>ims</servlet-name>
    
 <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
     <load-on-startup>1</load-on-startup>
  </servlet>
 
  <servlet>
        <servlet-name>CXFServlet</servlet-name>
        <display-name>CXF Servlet</display-name>
        <servlet-class>
            org.apache.cxf.transport.servlet.CXFServlet
        </servlet-class>
        <load-on-startup>1</load-on-startup>
  </servlet>

   <servlet-mapping>
     <servlet-name>ims</servlet-name>
     <url-pattern>*.do</url-pattern>
   </servlet-mapping>

    <servlet-mapping>
        <servlet-name>CXFServlet</servlet-name>
        <url-pattern>/services/*</url-pattern>
    </servlet-mapping>

Question 2:
Using  serviceClass attribute like:

  <simple:server id="pojoservice" 
serviceClass="demo.hw.server.HelloWorld" address="/hello_world">
      <simple:serviceBean>
          <ref bean="#yourProxyObjectID" />
      </simple:serviceBean>
  </simple:server>

Thanks
Jeff


ojs wrote:
> Willem2 wrote:
>   
>> You should use CXFServlet to handler the http request and not the spring
>> DispatcherServlet.
>> Since CXFServlet will replace all the http related transport to the
>> servlet transport, you endpoint will not try to start a jetty engine for
>> http transport listening.
>>
>> You can find the CXFServlet's web.xml here.
>> [1]https://svn.apache.org/repos/asf/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/web-spring.xml
>> [2]https://svn.apache.org/repos/asf/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml
>>
>>     
>
> Hello Willem,
>
> thanks for your help so far. It's a bummer, that CXF isn't as easy to
> configure as XFire is. I don't want to have another servlet, because I want
> to use the Spring MVC infrastructure (interceptors, custom mapping
> strategies, ...). I guess I can use Springs ServletWrappingController to
> wrap the CXFServlet - but this isn't a very good alternative compared to the
> XFireExporter.
>
> Another thing is: how to specify the Service interface? CXF currently tries
> to create an endpoint for my implementation (which is proxied). XFire has a
> serviceInterface property for that.
>
>
> Best
>
> Oliver
>
>   

Re: How to export non-annotated service in spring

Posted by ojs <ol...@siegmar.net>.

Willem2 wrote:
> 
> You should use CXFServlet to handler the http request and not the spring
> DispatcherServlet.
> Since CXFServlet will replace all the http related transport to the
> servlet transport, you endpoint will not try to start a jetty engine for
> http transport listening.
> 
> You can find the CXFServlet's web.xml here.
> [1]https://svn.apache.org/repos/asf/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/web-spring.xml
> [2]https://svn.apache.org/repos/asf/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml
> 

Hello Willem,

thanks for your help so far. It's a bummer, that CXF isn't as easy to
configure as XFire is. I don't want to have another servlet, because I want
to use the Spring MVC infrastructure (interceptors, custom mapping
strategies, ...). I guess I can use Springs ServletWrappingController to
wrap the CXFServlet - but this isn't a very good alternative compared to the
XFireExporter.

Another thing is: how to specify the Service interface? CXF currently tries
to create an endpoint for my implementation (which is proxied). XFire has a
serviceInterface property for that.


Best

Oliver

-- 
View this message in context: http://www.nabble.com/How-to-export-non-annotated-service-in-spring-tf4838545.html#a13873445
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to export non-annotated service in spring

Posted by Willem2 <ni...@iona.com>.
You should use CXFServlet to handler the http request and not the spring
DispatcherServlet.
Since CXFServlet will replace all the http related transport to the servlet
transport, you endpoint will not try to start a jetty engine for http
transport listening.

You can find the CXFServlet's web.xml here.
[1]https://svn.apache.org/repos/asf/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/web-spring.xml
[2]https://svn.apache.org/repos/asf/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/servlet/spring.xml

Willem.


ojs wrote:
> 
> 
> Willem2 wrote:
>> Can you show me your web.xml ?
>> There must be something wrong with your web.xml.
> 
> Sure, but I don't know what should be wrong with it. It starts my
> application and all requests are handled by springs DispatcherServlet (as
> wanted). BTW: My application is deployed in tomcat 6.0.14.
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <web-app xmlns="http://java.sun.com/xml/ns/javaee"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
> metadata-complete="true" version="2.5">
> 
>     <context-param>
>         <param-name>contextConfigLocation</param-name>
>         <param-value>
>             /WEB-INF/classes/config/spring/applicationContext.xml
>         </param-value>
>     </context-param>
> 
>     <listener>
>        
> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
>     </listener>
> 
>     <servlet>
>         <servlet-name>backend</servlet-name>
>        
> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
>         <load-on-startup>1</load-on-startup>
>     </servlet>
> 
>     <servlet-mapping>
>         <servlet-name>backend</servlet-name>
>         <url-pattern>/*</url-pattern>
>     </servlet-mapping>
> 
> </web-app>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-export-non-annotated-service-in-spring-tf4838545.html#a13866136
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to export non-annotated service in spring

Posted by ojs <ol...@siegmar.net>.

Willem2 wrote:
> Can you show me your web.xml ?
> There must be something wrong with your web.xml.

Sure, but I don't know what should be wrong with it. It starts my
application and all requests are handled by springs DispatcherServlet (as
wanted). BTW: My application is deployed in tomcat 6.0.14.

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
metadata-complete="true" version="2.5">

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/classes/config/spring/applicationContext.xml
        </param-value>
    </context-param>

    <listener>
       
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>backend</servlet-name>
       
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>backend</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>

</web-app>


-- 
View this message in context: http://www.nabble.com/How-to-export-non-annotated-service-in-spring-tf4838545.html#a13853725
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to export non-annotated service in spring

Posted by Willem Jiang <ni...@iona.com>.
Hi,

Can you show me your web.xml ?
There must be something wrong with your web.xml.

Willem.
ojs wrote:
> Willem2 wrote:
>   
>> You can use the simple front end custom server bean definition.
>> Please see [1] for more information.
>>
>> [1] http://cwiki.apache.org/CXF20DOC/simple-frontend.html
>>     
>
> I tried that, but it seems that simple front end tries to start a separate
> http server (jetty) instance?! Or did I misunderstand something?
>
>   

Re: How to export non-annotated service in spring

Posted by ojs <ol...@siegmar.net>.

Willem2 wrote:
> You can use the simple front end custom server bean definition.
> Please see [1] for more information.
> 
> [1] http://cwiki.apache.org/CXF20DOC/simple-frontend.html

I tried that, but it seems that simple front end tries to start a separate
http server (jetty) instance?! Or did I misunderstand something?

-- 
View this message in context: http://www.nabble.com/How-to-export-non-annotated-service-in-spring-tf4838545.html#a13853335
Sent from the cxf-user mailing list archive at Nabble.com.


Re: How to export non-annotated service in spring

Posted by Willem Jiang <ni...@iona.com>.
Hi,

You can use the simple front end custom server bean definition.
Please see [1] for more information.

[1] http://cwiki.apache.org/CXF20DOC/simple-frontend.html

Willem.
ojs wrote:
> Hello,
>
> I'm trying to switch from xfire to cxf - don't had much luck so far...
>
> My xfire configuration (in spring) looks like:
>
> <bean name="/myService"
> class="org.codehaus.xfire.spring.remoting.XFireExporter">
>     <property name="serviceInterface" value="myBean"/>
>     <property name="serviceBean" ref="myBeanImpl"/>
>     <property name="xfire" ref="xfire"/>
> </bean>
>
> So Spring's DispatcherServlet handles the request and forward request to
> /myService to this bean. The service I'm exporting isn't (and shouldn't be)
> annotated. Is there a similar thing in cxf to export a service as it is
> possible with xfire?
>
>
> Best
>
> Oliver
>