What is benefit of developing webservice using Apache CXF over normal JAX-WS with Java6 - cxf

Can some body expalain what is the benefit of developing JAX-WS webservice using apache CXF over normal JAX-WS provided by Java 6.

JAX-WS is only the api / specification - to use it you need an implementation. It can be something like CXF, Axis or the one provided by the application server (JBoss, Weblogic et..).
One advantage of using CXF is that you have more flexibility in terms of deployment. It can be deployed in a web container or you can use an embedded web container and runt it as a stand alone application.
CXF also provides integration with other frameworks like spring.
It also provides tools to work with schema / WSDL etc..

Apache CXF is a open source webservice framework which contains JAX-WE and JAX-RS and also it helps to integrate with spring framework
CXF Supports
1) XML , JSON Format
2)JAXB Data Binding
3) SAOP ,REST,HTTP protocal binding

I have recently completed the web service implementation with JAX-WS using reference implementation apache-cxf. And I found with CXF - integration with Spring is very easy. Moreover, It provides various features like:
Customization of Logging features
Inbound and Outbound interceptor
Application Level security
Easy Exception handling using custom Fault.
For more detail, if you want, please checkout this link: http://predic8.com/axis2-cxf-jax-ws-comparison.htm
And, I read above link, its preety helpful for me.
Thanks !

Related

How configure JAX-WS for the WLP v 16.0.0.4

I use jaxws-2.2 feature and need to know how to configure JAX-WS for the WLP v 16.0.0.4.
WLP uses Apache CXF implementation for JAX-WS. Apache CXF JAX-WS configuration includes the next two steps.
Create servlet class mapping (org.apache.cxf.transport.servlet.CXFServlet) in the web.xml
Create the JAX-WS endpoint configuration (jaxws:endpoint) in the cxf-servlet.xml
Maybe there are the other ways for configuration JAX-WS Apache CXF implementation on Liberty, however, I don't know it. All examples for cxf-servlet.xml that I found related to Spring:
https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Fuse/6.1/html/Deploying_into_a_Web_Server/DeployCxf.html
Apache CXF http://cxf.apache.org/docs/jax-ws-configuration.html
IBM https://www.ibm.com/developerworks/websphere/library/techarticles/1001_thaker/1001_thaker.html (please see attached pdf and sample application).
I couldn't find the cxf-servlet.xml example for the pure Java EE application without Spring (and any others 3rd party) dependencies.
Kind regards,
Alexander
Once you've added the jax-ws feature to server.xml, the easiest thing is to create a war file with a class in it, just like you would a servlet, but this class has an #WebService annotation on it instead of an #WebServlet. The public methods will become your webservice operations. WSDL will be produced automatically when you deploy the war file. It's exact URL is probably detectable by looking at Liberty's messages.log file. Web.xml is optional.
It's a big mistake to deal with the JAX-WS implementation provided within WLP (here cxf)...
You don't need specific "configuration", just stick with the JAX-WS specification that has lots of annotations to define the services, the operations, the endpoints and the parameter mapping (JAX-B) etc. You don't need any configuration file
In short, just create a POJO, annotated the class with #WebService and the methods with #WebMethod
You'll find lots of tutorial on the web. One from Oracle is here
Check the classes in the javax.jwsand javax.jws.soap packages in the official jee6/jee7 javadoc
It's the same principle for REST services, ie plain annotated POJO classes..

Apache Camel on a JAXRS API?

Could anybody explain how Apache Camel is able to behave as a routing and mediation engine on a JAXRS API?
As far I've being reading about I've not been able to figure out what's it for?
You can consider Apache Camel as a great integration framework. It doesn't provide functionality itself, but it makes easy to glue multiple services and protocols together.
Apache Camel can expose a REST endpoint using the CXFRS component. This means it listens for a REST call on certain endpoint (URL). On invocation it doesn't invoke the implementing bean (service) itself, but executes a defined mediation route (invoke a route with its Exchange object).
It is very useful when you need to integrate multiple services or translate the call to other protocols. You can implement a REST service by a bean itself and it's ok until the bean provides some functionality or data itself. For integration you often need more flexibility to integrate multiple sources and protocols. Then Apache Camel can be much more practical tool.

JAX-WS with Apache CXF under CDI/Weld

I have seen the other questions on CXF under CDI but they all seem to be for JAX-RS style web services.
Is JAX-WS possible in this configuration? If not, how can I expose a JAX-WS service using CDI/Weld in a non-EE container (Tomcat 8)?
If you want to use CDI and JAX-WS in Tomcat then most possibly the easiest you can do is to use Apache TomEE.
TomEE is basically a standard Apache Tomcat, but pimped with lots of JavaEE libs. It brings a full CDI container, JAX-RS, JAX-WS etc.
For JAX-WS you should take the 'plus' variant.
If you want it really just embedded or smallish (in size, not in power), then you can also take a look at Apache Meecrowave and bundle the JAX-WS part of CXF to it.
Meecrowave is a EE8 technology based smallish (9MB) Application Server which can be used standalone or embedded (via Meecrowave#bake()). It's pure Apache:
Tomcat (Servlets-4.0), OpenWebBeans (CDI-2.0), Johnzon (JSON-P_1.1, JSON-B_1.0), CXF, log4j2.
First, you have to enable CDI on tomcat. See here.
In my case, #Inject did not work on classes with #WebService but I was able to inject using CDI.current().select(MyClass.class).get().
It did not work on #PostConstruct though, but you can use it inside a #WebMethod.
[Note] I was using Metro instead of Apache CXF

JAX-RPC runtime for Tomcat

I have ported a Java EE web application from JBoss 4.0.5/Java 5 to Tomcat 6.0.33/Java 6.
The web application exposes some web services. They were implemented as JAX-RPC web services in JBoss, I have adapted them as JAX-WS web services using CXF 2.6 as the implementation run-time. Now I have been requested to make available in the new environment (Tomcat 6.0.33/Java 6) also the JAX-RPC web services for compatibility with existing clients. The two versions of the same web services would of course be available through two different end point URLs.
The JAX-RPC web services in JBoss 4.0.5/Java 5 are implemented using Spring (the implementation class extends org.springframework.remoting.jaxrpc.ServletEndpointSupport, found in spring-remoting-2.0.8.jar) but I cannot guess which is the underlaying implementation framework for JAX-RPC made available by JBoss. I just can see that the configuration files are webservices.xml and jaxrpc-mapping.xml.
I tried to "replicate" that Spring configuration in Tomcat but when I try to retrieve the WSDL I get an error javax.servlet.ServletException: Class pack.age.MyEndPoint is not a Servlet. Indeed that class (the JAX-RPC end point implementation class) is not a servlet but under JBoss 4.0.5/Java 5 it is declared in web.xml as a servlet and it works.
Could you please help? I imagine I just have to supply the proper JAX-RPC implementation framework to Tomcat (I would like to avoid AXIS because it uses different configuration files). Thanks in advance.

Using ServiceMix to Proxy Remote Web Service

This might be obvious but i just still don't understand how i'd do it with ServiceMix :
An external web service http://mypartner.com/service/partnerService
My platform is for example http://myservicemix.com/
I'd like to use OSGI bundles
Is this what i need ? :
A cxfbc:provider (this is the one that talks to the remote service, just a wsdl in the bundle right ?)
A camel route and transformations to bridge the two
A jaxrs:server (i'd like to expose it as a REST service)
The cxfbc is a JBI component. JBI is essentially dead/legacy, so I suggest to not use that for new projects. You can read more about JBI is dead here: http://gnodet.blogspot.com/2010/12/thoughts-about-servicemix.html
So Apache ServiceMix is the server where you can host your Camel applications. So I suggest to look into how to do a webservice proxy with Camel.
For example there is an example with Camel
http://camel.apache.org/cxf-proxy-example.html
That example is OSGi ready and can be deployed in Apache ServiceMix.
Also check out some of the CXF examples that are shipped with Apache ServiceMix, in the examples directory
The Camel CXF component can do both REST and WS.
Also there is the camel-restlet component for REST support as well: http://camel.apache.org/restlet

Resources