Remoting from iOS to Java/Spring backend - java

In our application we have an Adobe Flex client that communicates to our Java/Spring backend via a facade (using AMF) that is exposed via Spring.
Any recommendations on how I could leverage this facade to make remote calls from iOS? Note that I would prefer backend frameworks that would be reusable from other clients (Android, etc).
I hear about JSON & RESTful web services. Would there be a way to rather easily get existing facade services to be exposed as RESTFul web services that uses JSON for object serialization?
Or would you recommend something different?
Any information and/or pointers will be appreciated!
Update:
So we have one option so far for this: JSON requests and responses via Spring
Anybody want to suggest any other ways?

Spring supports JSON requests and responses (see for instance, this article from the Spring In Practice blog), largely through the use of annotations.
While I don't think that it is likely that you'll be able to go through your existing AMF facade, I think that it should probably be pretty straight-forward to create a JSON-over-HTTP facade using the same underlying Spring controllers (assuming that you're using Spring MVC).
Edit: Whether the JSON-over-HTTP facade that you create is truly RESTful depends largely on your implementation.

Related

Consuming RESTful API in Java, generating artifacts.

I am tasked with creating a layer in Java/Spring that consumes web services from a couple different providers. These services define specific request beans but the end points do not publish XSD information.
What would be the best way to generate the artifacts required to consume these services? It seems building our own request objects is not the best way of doing things.
REST services do not offer XSD as the WSDL of a traditional SOAP service. Some REST frameworks offer WADL, or the may user Swagger.io to describe the service, or expose documentation like Spring boots actuator /docs.
If there is no such documentation, and you can't get the source code for the system you are integrating with, I recommend that you build your own set of Java POJOs so you can interface with the service in a typed manner.
I have done that for multiple systems that expose (online) documented REST services, but do not provide a set of DTO that you can use when consuming them.

How I develop webservice in spring that can be exposed as REST and SOAP both?

I have requirement to develop webservices in spring that should be in both form SOAP and REST.
So what is good way to write such code with minimum code duplication and write it with industry standards.
Pls provide some example or some helpful link.
Use a multi layer architecture where you have common business in service layer that are used by presentation layer (soap and rest). With spring it's realy easy to implement such architecutre

How can I communicate Servlet from Swing

I develop a CRUD Spring, Servlet/JSP application. I will develop a desktop Swing application with same functionality. My question is that possible to communicate and resuse servlets on swing application (not applet)?
Yes, by making http requests. You can do them with multiple tools. Two of them:
new URL(..).openConnection()
apache http components
since you tagged spring, if you are using it with swing, you can use its RestTemplate. It's used to invoke restful services. You can expose your logic as restful services through the servlets (or spring-mvc), and consume them with RestTemplate
The Rest idea above is pretty good. In fact, by using Spring and it's proxies, you could use any kind of webservices (RESTFul or WSDL), and Spring would make it transparent for you.
Please check some examples in the Spring manual. Take a look at how to create proxies using service interfaces.
Best regards.
since its all via HTTP, and mechanism as suggested above can work.
Or you can even open bytestream to the server and read/write using that stream.

How do I easily expose CRUD operations, via a Java based Web Service, on an existing data model?

I have an existing domain model annotated with JPA annotations that I would like to easily expose CRUD operations on via Web Services. I already have DAOs to perform CRUD operations on all of my entities in my domain.
Does anyone know of an way to do this that does not involve a tremendous amount of effort?
It depends on how my operations and services and what you call "a tremendous amount of effort." You're likely to be disappointed if doing anything more than pushing a button and having your wishes come true is too much.
But there are three parts to your problem:
Writing DAOs that expose the CRUD operations. I'd recommend an interface-based approach.
Exposing these as "contract-first" web services, either SOAP or REST.
Mapping HTTP requests and responses to your API.
I'd recommend Spring, because it'll help with DAOs, web services, and mapping. But I don't know if it'll be as effortless as you want it to be.
You can use Apache CXF in combination with Spring ROO to achieve this.
Please see this post for more details: http://forum.springsource.org/showpost.php?p=284028&postcount=4
Throw some annotations on that DAO, like #WebService and #WebMethod and use your JAX-WS implementation of choice. You can use JAX-WS Commons Spring for Spring integration.

Java Spring remoting options

A little context: I would like to separate the Java application I'm writing into a more or less typical server-client model. I would provide a "server" which takes care of business logic and persistence, but write it in a very service oriented fashion. Any front-end code (GUI) would then call upon the server to provide the functionality in a user friendly fashion.
As I'm writing the application using Spring (and an ORM framework), it would make sense to explore the usual suspects to expose the server functionality, with the usual suspects being RMI, Spring HTTP, Hessian, web services, etc (the Spring natively supported options). These are well well documented, both in reference documentation and on here.
However, for the actual question: are there any less obvious, more exotic options I could consider to use for exposing my server services?
It's important (as always) to get the right balance between ease of use (from a front-end POV), performance and scalability. For example; since I've thought about providing the Spring-BlazeDS integration in the server any way (for Flex/AS3 clients), it dawned on me that BlazeDS provides a Java-native API for calling AMF services.
Any pointers are much appreciated.
I would recommend BlazeDS if you have a Flex front end and Spring HTTP if not. Both eliminate the non-productive work introduced by having to translate XML to objects and back again.
Spring HTTP is especially attractive because you can write POJO Spring service interfaces just as you always do, deferring the choice to expose via HTTP remoting until the end. You keep your options open that way. If you decide that Spring web services work better for you later on, you can keep re-using the same POJO Spring interface.

Categories