I'm reading tutorial for Apache CXF and I see one of the samples is using Spring framework. Looking at the following example I don't understand how it is different from just using Spring (it seems CXF doesn't add any add'l functionality?) http://cxf.apache.org/docs/writing-a-service-with-spring.html
Apache CXF is a Services Framework which can be used to create web services and support JAX-RS/JAX-WS/SAAJ etc (various specifications for developing Web Services).
From there documentation they support the following:
Multiple Transports, Protocol Bindings, Data Bindings, and Formats
Transports: HTTP, Servlet, JMS, In-VM and many others via the Camel transport for CXF such as SMTP/POP3, TCP and Jabber
Protocol Bindings:SOAP, REST/HTTP, pure XML Data bindings: JAXB 2.x, Aegis, Apache XMLBeans, Service Data Objects (SDO), JiBX
Formats: XML Textual, JSON,FastInfoset
Extensibility API allows additional bindings for CXF, enabling additional message format support such as CORBA/IIOP
Where as Spring is an Application Framework and supports
IOC Container / DI Framework
MVC Framework (Web Applications and Web Services support)
Data/JPA wrappers etc
To make your enterprise application creation experience smooth.
Related
I have been working for a while with Spring micro-services and have no come across Apache Camel as a tool for building micro-services. I'm unclear -- is Apache Camel a replacement for creating micro-sevices with Spring Boot or does it add functionality / short-cuts to developing such services with Spring Boot? It's already fairly simple to create microservices with Spring Boot so it's hard to imagine what Apache Camel would add but that is the essence of my question.
Apache Camel has nothing to do with microservices.
It's an implementation of the Enterprise Integration Patterns: https://www.enterpriseintegrationpatterns.com/
Apache Camel provides an implementation for most of the patterns from the book from Gregor Hohpe and Bobby Woolf. Plus a variety of inbound and outbound endpoints to integrate with systems like the file system, FTP, HTTP, Messaging, Facebook etc.
Find more information on the website: https://camel.apache.org/
There is a Spring Boot Starter project to run Camel in a Spring Boot application:
https://camel.apache.org/spring-boot.html
what Apache Camel would add, that is the essence of my question
In service of declaring REST based microservices, Camel's REST DSL provides a fluent API for declaring microservices. Take for example:
rest("/books").produces("application/json")
.get().outType(Book[].class)
.to("bean:bookService?method=getBooks(${header.bookCategory})")
Should tell you at a glance that requests to the path /books will get you a List of Book, as long as you send a request parameter named bookCategory. This is mapped to a POJO bean called bookService.
Spring Boot is a framework which simplifies application packing and startup while Spring is the actual framework which has libraries for performing various tasks.
Technically, we can use Camel for building micro-services as well and many aspects of camel depend on Spring. If you foresee many integration related functionality like sending email or communicating with other system, you can use also use Hexagonal architecture.
I new to SOAP web service. In my project there is a requirement where I need to consume the SOAP web service in spring MVC. I tried search in google I am not getting simple example to integrate the SOAP services with spring MVC.
I have few other question as well.
What is JAXB? As per my understanding the JAXB is used for marshalling and unmarshalling the objects from service.
2.Whether I can use both restful web service and SOAP web service together in same spring mvc application?
3.What is different between Spring-WS and JAX-WS?
What is JAXB? As per my understanding the JAXB is used for marshalling
and unmarshalling the objects ?
Yes, JAXB is a framework which can be used to convert Java object into an XML file (stream) and vice versa.
Java Object to an XML file conversion is called marshalling and the opposite is unmarshalling.
This technique will be useful when two applications are exchanging the business data using XML.
2.Whether I can use both restful web service and SOAP web service together in same spring mvc application ?
Yes, you can use both together with in the same project as per your business requirements.
For example, assume that your application (project) might need some data from two external sources i.e., external system1 (assume that it exposes it's endpoints in SOAP) and
external system2 (assume that it exposes it's endpoints in REST), your application has to interact with both of those to exchange the data.
Similarly your application might need to expose few services in REST and few services in SOAP (assume that the other system can consume only SOAP), it is all about agreeing between different systems on data exchanging formats.
3.What is the difference between Spring-WS and JAX-WS ?
JAX-WS is a specification & implementation built into JDK for consuming/producing SOAP services.
Spring-WS is a Spring API for consuming/producing SOAP services.
There are two types of SOAP frameworks available for the development of projects:
Compliant to JAX-WS - like Apache CXF, Apache Axis2, etc..
Non compliant to JAX-WS - Spring-WS
You can look at here for the list of web service frameworks
I want to develop a web application using websocket.
I have found two solutions for this task:
Using Spring websocket (included in Spring 4) - I am already familiarized with Spring
Using Atmosphere framework - I've read the docs, it seems to be a mature framework.
I want from the websocket framework to provide a fallback-support in case when the
browser isn't HTML5 compliant, also, I need a client-library for android.
I see that Atmosphere provides support for Socket.IO library, which I want to use on
browser client side. I see that Spring websocket provides only SockJS support over STOMP.
Can I use the same library, Socket.IO, in Spring websocket?
Do you recommend me to use Atmosphere + Spring (for building the RESTFul API) in the same
project?
Thank you
I would suggest going for the WebSocket support in Spring. If you are already using Spring, this will give you a similar programming model plus all these features:
Fallback options with SockJS
Subprotocol support with STOMP
Integration with full blown STOMP broker (like RabbitMQ)
HttpSession and WebSocket Session sync (using Spring Session)
WebSocket security (in the upcoming Spring Security 4)
SockJS Java client (for application to application communication and performance testing, haven't tried it on Android yet but might work)
Runtime Monitoring
Active community with fast response times to requests
The WebSocket support has been around since Spring 4, tested and refined for over a year now. A production ready solution which I'm using in my projects.
I have web application on Spring MVC and looking for SOAP consumer - frameworks to be used with Spring MVC. The web app is only the consumer and doesn't host any web service.
Options I am looking for SOAP client are :
1. JAX-WS
2. Spring MVC & Spring-WS
3. Apache Axis or CXF
4. Spring Integration or Camel. Can these be used for consumption of
services too? Won't that be overhead?
What do you suggest? Please recommend the best option if also not in the above list.
Thanks in advance.
Look at this excellent post about this subject.
Which framework is better CXF or Spring-WS?
My advise based on the fact that you only have to develop one client, is to consider making your choice based on your context to optimize your productivity and avoid adding tones of layer and libs in your app:
Pure Java EE app or already using Spring APP
Your current Application Server : Jboss for example already provide a CXF implementation that is very suggested to use
Service providers "age": I have met some problems in calling AS400 or old IBM system webservices. Any client was not working.
Your IDE and Plugins : for example, if you have eclipse, Axis/CXF plugins are very interesting.
Concerning Camel, it is interesting if you have different source and destination like HTTP to JMS.
For Camel, read this post:
What exactly is Apache Camel?
looks to me you need tomcat or some other servlet engine for the web part.
what about data access part using hibernate and jms? Thanks.
No, you don't need an application server, you can see Spring as a proprietary, modular application server implementation / adapter. But you still need an a servlet container.
Data access part: you can use hibernate and some standalone connection pool
jms: Spring is not a JMS provider, but it nicely integrates POJOs with any JMS provider
Spring also has comprehensive transactions support
Finally you have jmx and aop support built-in and easy integration with bean validation, jpa, web services, rmi, jci, task scheduling, caching...
As you can see you can either use certified application server and Java EE stack or built on top of Tomcat and pick Spring modules you need. Sometimes Spring uses standard Java EE APIs (like JPA), more often it builts its own.