Question

When one wants to set up an API for a webservice with Java EE, what is the best procedure to design and realize such an API?

Having never used persistence before, I always drew out my UML datamodel and structured a database with a SQL client tool then build my application on top of it.

I get the idea that most Java EE applications are built starting from entity classes and services. Or from XSD and WSDL files. Is this true? Is there a difference between how one best creates SOAP and REST apis?

Where is the structure decided and what comes first? How are persistence systems best designed? And on what basis? What tools are helpfull? Any extra information and especially reference is desirable here! I just want to get more feeling with the bigger picture.

Was it helpful?

Solution

It's still a good idea to figure out the correct data model first. The other thing you need to figure out before starting to code is the interface architecture: what calls you are going to support, what arguments the calls will have, and what data will be returned. Once you understand those two things, the actual Java coding can go much more smoothly.

OTHER TIPS

If you are just asking for how to get started with developing a java rest api, I would first look at some of the specifications.

If your question is just about technology to learn, Heres the general stack I use:

  • RESTful services are provided through the JAX-RS API through the reference implementation Jersey
  • Object to relational data mapping provided through the Java Persistence API via Apache OpenJPA (almost a reference implementation, little less cruft than hibernate)
  • Object serialization/deserialization provided through the JAXB API via the Jackson Object Serialization API
  • Configuration and dependency management provided through JSR-299 via Google Guice

If your question is about API design...

Make sure you write down your api. Make sure the urls make sense, and that you follow best practices when making a url. Your interface between the outside world and your software is that URL. The json you expect and the JSON you return is the most important thing to get right. Even if your software sucks, so long as your api is well thought out and the contract is sound, it will be okay.

Make sure you really understand what you want to input and output before you put it to code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top