I have implemented Restful web services using spring technologies. Now, I need to integrate these services to work together on the same context using spring integration.
How To make web services methods as endpoints ? How can I realize the coreography of web services ? How It is possible to transform messages exchanged between web services ?
The spring-integration tag has links to lots of resources.
Related
I have a Spring web application and an standalone application written on C#. Only Spring application has an access to DB, so I want to implement data exchange between Java and C#. The data isn't large (100KB / Min or so). Application will be placed on the same machine. What is the best way to integrate a communication? Does Spring Framework has a module to work with?
Spring certainly does have a module for doing this, it's called Spring Integration. You can define inbound and outbound channels/gateways and before the data comes in or out do any transformation on it needed to get it in the right format. Pretty standard functionality for doing enterprise integration.
Alternatively if that's too heavy weight you could expose a RESTful webservice in the spring application using the #RestController annotation and call that api from C# application. Another alternative would be to expose a spring-ws Web service in the spring application and write a Soap client that calls it in the C# application.
I have written a SOAP based web service which runs fine on a Tomcat server. The Web Service service itself is a Spring MVC based web service that runs on the Tomcat application server.
Now i need to write a Thick client which will be a standalone Java app that will use the services of the web service. I think i am correct in that the client only needs to know about the service details (i.e. operations) and nothing else.
What i am not sure of is the architecture and environment i should use for the client. The client application will be based on Swing but is it possible to use Spring with Swing together?
On the web service i have the following setup
view --> Service --> Model
The client application is basically a configuration tool. It uses the web service to configure user accounts. This means that the client application does not actually write anything to any database. It just uses the services of the web service to make changes to 'user account' and probably view list of accounts.
My question really is
- Is an MVC design suitable for such a use case
- Usually Spring is used for web based applications. Is there any benefit in using Spring with the Swing based client?
- Are there any alternative or better solutions/design/architecture that would achieve the same?
An example showing Spring used in conjunction with a Swing application would be very usefull.
Thanks in advance.
Spring MVC is not appropriate for a Swing-based client. Use the core Spring framework and a JAX-RS implementation like Jersey to provide simple REST web services in tomcat. Jersey also provides a corresponding client API that you can use within your Swing application to invoke the REST services.
If you have decided upon Swing as your platform, there are two options you can look at:
(1) Net Beans Rich Client Platform
http://netbeans.org/kb/trails/platform.html
(2) You can roll up your sleeves and write your own app using a low level yet extremely flexible framework called Swixml
http://www.swixml.org/
Give Swixml a good try before you try others, it may surprise you.
You can implement Swing-based thin client application with Spring Integration backend serving as a integration tier. It can expose gateways accepting simple Java types or DTOs. Your Swing presenters / controllers interacts with these components in order to call remote webservices.
I have an existent web application, I'd like to add Groovy to this web app so that I can develop web service providers easily if possible.
Is there a way to write a service class (like Grails service classes) and expose this class as ws without much pain ?
Grails uses the same thing : after adding one line to the service class, that class will be exposed automatically as a web service.
Regards
GroovyWS is a SOAP based implementation of Apache CXF.
After some quick searching I found two tutorials that may be of help.
One using Jersey and the other using Restlet. The Jersey one seems simpler.
Creating RESTful services with Jersey and Groovy
Building RESTful Web Apps with Groovy and Restlet, Part 1: Up and Running
Is there anything in Java that's the equivalent of WCF Data Services ?
Does Spring have the capabilities to expose databases as a RESTful web service like WCF Data Services ?
Thanks !
These are two separate capabilities - database access and REST web services - but Spring indeed has both.
You can access databases in Spring using JDBC, Hibernate, TopLink, or iBatis.
You can expose web services as SOAP using Spring web services or RESTful web services using Spring 3.x.
You can put the two together to achieve your stated goal.
I am using Netbeans 6.8. I can see an option to create a web service in my independent ejb module but i can't seem to find an option to create a RESTful based web service in my ejb module. Is there any kind of restriction in ejb module that i can only create SOAP based web service and not RESTful? or is it the bug of Netbeans 6.8?
Chapter 2.6 of the EJB3 specs:
To support web service
interoperability, the EJB speciļ¬cation
requires compliant implementations to
support XML-based web service
invocations using WSDL and SOAP or
plain XML over HTTP incon- formance
with the requirements of the
JAX-WS[32], JAX-RPC[25], Web Services
for JavaEE[31], and Web Services
Metadata for the Java Platform [30]
speciļ¬cations.
In other words: EJB3 can be exposed only as SOAP web service.
REST is just HTTP, usually implemented with servlets, so it would naturally be added to a WAR file that may or may not be packaged into an EAR with EJBs.
I don't believe that EJBs know or care about SOAP or REST. EJBs use RMI as their communication protocol of choice.
I found an article about EJB 3.1 and JSR-311 REST but I've to admit that I never tried it.
Write a wrapper class to the EJB which you are going to mark it as restful webservice with Jax-rs annotations with support of CXF rest api or Jersey api.