You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by pierre betz <pi...@gmail.com> on 2008/12/17 23:30:27 UTC

using cxf without spring ?

Hi everybody,
I'm pretty new to cxf uses, as I was using Axis the years before...

I was looking at some tutorials explaining me how to use cxf to build web
services,
but every tutorials I found were using spring framework too.


I know how to build a service, and run a server like in the apache cxf
tutorial, server launched within a main function.
The problem is when I want to call these services with jsp pages...

for example : I've an application server with my databases, I've a web
container (number1) with my service.
I want to call these services from another web container (number2), using
jsp pages.

do I need to have the spring framework within the number1 container to
deploy and make the services work ?
Because in all the tutorials, I found these lines in the web.xml file :

<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">


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


(with the cxf.xml declaration)

Like explaining that the listener is a spring listener....

and in the cxf.xml :

<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 ........./>
</beans>



so, how can I use cxf without spring, and how to explain the endpoint
references, listeners... ?



and, can I call these services wiht jsp pages, just knowing the interfaces
and the wsdls ?

if you have a good tutorial using jsp pages and not using spring, it could
be very useful for me !




thanks a lot, I hope I'll can help others in near future !

Re: using cxf without spring ?

Posted by Glen Mazza <gl...@gmail.com>.
CXF relies on Spring for much of its functionality, saves a lot of wheel
reinventions that way.  In some limited cases, however, you can avoid using
it with CXF--but it may be needed when you're using JSP, I'm unsure here. 
GlassFish Metro is Spring-free, but I don't think they have JSP support.

Glen


pierre betz wrote:
> 
> Hi everybody,
> I'm pretty new to cxf uses, as I was using Axis the years before...
> 
> I was looking at some tutorials explaining me how to use cxf to build web
> services,
> but every tutorials I found were using spring framework too.
> 
> 
> I know how to build a service, and run a server like in the apache cxf
> tutorial, server launched within a main function.
> The problem is when I want to call these services with jsp pages...
> 
> for example : I've an application server with my databases, I've a web
> container (number1) with my service.
> I want to call these services from another web container (number2), using
> jsp pages.
> 
> do I need to have the spring framework within the number1 container to
> deploy and make the services work ?
> Because in all the tutorials, I found these lines in the web.xml file :
> 
> <?xml version="1.0"?>
> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
> Application 2.3//EN"
> "http://java.sun.com/dtd/web-app_2_3.dtd">
> 
> 
> <web-app>
>   <listener>
>     <listener-class>
>       org.springframework.web.context.ContextLoaderListener
>     </listener-class>
>   </listener>
> </web-app>
> 
> 
> (with the cxf.xml declaration)
> 
> Like explaining that the listener is a spring listener....
> 
> and in the cxf.xml :
> 
> <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 ........./>
> </beans>
> 
> 
> 
> so, how can I use cxf without spring, and how to explain the endpoint
> references, listeners... ?
> 
> 
> 
> and, can I call these services wiht jsp pages, just knowing the interfaces
> and the wsdls ?
> 
> if you have a good tutorial using jsp pages and not using spring, it could
> be very useful for me !
> 
> 
> 
> 
> thanks a lot, I hope I'll can help others in near future !
> 
> 

-- 
View this message in context: http://www.nabble.com/using-cxf-without-spring---tp21063011p21063677.html
Sent from the cxf-user mailing list archive at Nabble.com.


Re: using cxf without spring ?

Posted by Julio Oliveira <ju...@gmail.com>.
Hi

I'm using FUSE CXF now, try this example and tutorial.  www.fusesource.com


I don't have any application WS working yet, but i think there is a lot of
possibility and examples there.

-------------------------------------------

On Wed, Dec 17, 2008 at 9:50 PM, Ian Roberts <i....@dcs.shef.ac.uk>wrote:

> pierre betz wrote:
> > and, can I call these services wiht jsp pages, just knowing the
> interfaces
> > and the wsdls ?
>
> You can always use wsdl2java to generate stub code that you then call
> from within your JSP page in the usual way
> (http://cwiki.apache.org/CXF20DOC/developing-a-consumer.html).  But if I
> wanted to do this I would probably create the client stubs using Spring
> and then pull them from the application context in my JSP page and use
> them there, that way you can share a single client across all your pages
> rather than creating a new one at every request.  With
>
> <jaxws:client id="helloClient"
>              serviceClass="demo.spring.HelloWorld"
>              address="http://localhost:9002/HelloWorld" />
>
> in your Spring configuration file you can then do
>
> HelloWorld client = (HelloWorld)WebApplicationContextUtils
>      .getRequiredWebApplicationContext(application)
>      .getBean("helloClient");
>
> in your JSP to fetch the shared stub object.
>
> Stepping up onto my own soapbox for a moment... I do wonder why so many
> people posting to this list are so anti-Spring.  Spring is a very
> powerful tool, and the way it is designed you can just pick and choose
> the bits you want.  You don't have to code your application in a
> particular way to be Spring-aware, in fact in a well-written application
> most of your code shouldn't know (or care) whether Spring is involved or
> not.  A CXF example: if your class Foo needs to call a web service
> XYZService then it doesn't have to worry about how to create a stub for
> the service or where to obtain one from, you just declare a
> setXYZService method, and at runtime Spring handles the wiring for you.
>  But now if you want to write a unit test for Foo you can easily inject
> a mocked XYZService and Foo won't know the difference.
>
> I suppose what I'm trying to say is don't let the size and complexity of
> the whole Spring framework scare you off.  The core inversion of control
> container (which is all you'll need in many cases) is only a small part
> of the whole framework and is well worth, if not mastering, then at
> least learning the basics.
>
> I'm sorry, it's late, I'll stop evangelising now :-)
>
> Ian
>
> --
> Ian Roberts               | Department of Computer Science
> i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK
>



-- 
Saludos

Julio Oliveira - Buenos Aires

julio.julioOliveira@gmail.com

http://www.linkedin.com/in/juliomoliveira

Re: using cxf without spring ?

Posted by Ian Roberts <i....@dcs.shef.ac.uk>.
pierre betz wrote:
> and, can I call these services wiht jsp pages, just knowing the interfaces
> and the wsdls ?

You can always use wsdl2java to generate stub code that you then call
from within your JSP page in the usual way
(http://cwiki.apache.org/CXF20DOC/developing-a-consumer.html).  But if I
wanted to do this I would probably create the client stubs using Spring
and then pull them from the application context in my JSP page and use
them there, that way you can share a single client across all your pages
rather than creating a new one at every request.  With

<jaxws:client id="helloClient"
              serviceClass="demo.spring.HelloWorld"
              address="http://localhost:9002/HelloWorld" />

in your Spring configuration file you can then do

HelloWorld client = (HelloWorld)WebApplicationContextUtils
      .getRequiredWebApplicationContext(application)
      .getBean("helloClient");

in your JSP to fetch the shared stub object.

Stepping up onto my own soapbox for a moment... I do wonder why so many
people posting to this list are so anti-Spring.  Spring is a very
powerful tool, and the way it is designed you can just pick and choose
the bits you want.  You don't have to code your application in a
particular way to be Spring-aware, in fact in a well-written application
most of your code shouldn't know (or care) whether Spring is involved or
not.  A CXF example: if your class Foo needs to call a web service
XYZService then it doesn't have to worry about how to create a stub for
the service or where to obtain one from, you just declare a
setXYZService method, and at runtime Spring handles the wiring for you.
 But now if you want to write a unit test for Foo you can easily inject
a mocked XYZService and Foo won't know the difference.

I suppose what I'm trying to say is don't let the size and complexity of
the whole Spring framework scare you off.  The core inversion of control
container (which is all you'll need in many cases) is only a small part
of the whole framework and is well worth, if not mastering, then at
least learning the basics.

I'm sorry, it's late, I'll stop evangelising now :-)

Ian

-- 
Ian Roberts               | Department of Computer Science
i.roberts@dcs.shef.ac.uk  | University of Sheffield, UK