Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
What are the best frameworks for implementing both client and server REST frameworks in Java? I've been struggling a little to find an easy to use solution.
Update: Both Jersey and Restlet seem like good options. We'll probably use Restlet but we'll experiment with both.
Jersey is really easy for both. To write web services, you use annotations:
#Path("/helloworld")
public class HelloWorldResource {
// The Java method will process HTTP GET requests
#GET
// The Java method will produce content identified by the MIME Media
// type "text/plain"
#Produces("text/plain")
public String helloWorld() {
// Return some cliched textual content
return "Hello World";
}
}
For a client:
Client client = Client.create();
WebResource webResource = client.resource("http://localhost:8080/helloworld");
String s = webResource.get(String.class);
System.out.println(s); // prints Hello World
Restlet sounds like it should provide what you're looking for:
Support for client and server (in a relatively symmetric api)
Smart url binding
mime type understanding (given accepted mime types, it will ask your resources for their representation in that type)
Supports JAX-RS annotations (just like Jersey)
Take a look at dropwizard too.
Restlet also support annotations in its 2.0 version, both on the client and server-side. The JAX-RS API is also supported as an extension.
Here is a simple example for server-side:
public class HelloWorldResource extends ServerResource {
#Get
public String represent() {
return "hello, world";
}
}
On the client-side:
// Outputting the content of a Web page
new ClientResource("http://www.restlet.org").get().write(System.out);
For further documentation, check this page.
There's JBoss' new RESTEasy library. It appears to be under rapid development since its initial launch. I've no idea if it's any good; it's on my 'check it out' list.
I haven't used it personally but some teams that I work with are using Spring 3 MVC. REST in Spring 3: #MVC looks like a good blog post overview. The RESTful features include "URI Templates", "Content Negotiation", "HTTP Method Conversion", "ETag support" and more.
Edit: Also, see this question: Can anyone recommend a Java web framework that is based on MVC and supports REST ?
You could take a look at the CXF JAX-RS implementation. For complete list of its features check the CXF web site for JAX-RS.
The community behind the project seems to be very active (July 2013). An indication of that is the number of messages per day in the CXF mailing lists.
I can recommend Apache wink, a new framework still in incubation mode, but very mature and high quality.
http://incubator.apache.org/wink/
It implements the JAX-RS specification, it has both client & server framework for REST development.
Apache is standing behind this project - that's always a good sign (and a good license :-) )
What I love most about this framework is the intuitive integration with Spring, it's very useful if you want your framework to be easily configured and extended.
UPDATE: Xydra Restless is not longer maintained +++ If your are using Goolge AppEngine before they release a "reserve instance" feature, you might consider Xydra Restless which has few features but loads fast.
My favourite is Spring MVC, you have support for both, client and server side... And you have Android support too =)
For example, you can see a example of Spring Android here
Related
I am new to alfresco, I want to create a program that is capable of extracting a custom aspect's properties metadata, I've found people talking about Alfresco opencmis extension but i didn't know how to use it, is there any tutorial i can follow?
You should not need the opencmis extension if you are using a reasonably new release of Alfresco and the CMIS version 1.1 binding. All you need is a CMIS client for your favorite language.
You can take a look at this project for Alfresco Public API examples, keeping in mind that what you want is the on-prem use case, not the cloud use case.
This page also has good resources:
https://www.alfresco.com/cmis
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am coming from Node.js background and have quite a good understanding of RESTful web services.
Now I am trying to build RESTful web services using Java. I understand core Java but completely new to Java based web development.
I come to conclusion after some tutorials that I need to use Jersey framework to build my RESTful API. I understand that Jersey is some sort of reference implementation of JAX-RS.
But I fail to understand relationship between various other terms and components like JAXB, Jackson, EclipseLink Moxy, jersey-media-moxy, Jettison, JSON-P JSON, XML, etc. that come across my readings. The only thing that I could conclude was it is not so straight forward like JavaScript to covert Java objects into XML or JSON equivalent.
My question is what is the relationship between these terms mentioned above and how they fit together if I am developing a Java based RESTful API.
There sure is a lot of terminology in the Java world and that can create a significant learning curve for new developers. It's not that it's particularly difficult to pass JSON or XML documents around using Java, it's just that the various bits and pieces you need to do it have sprouted terminology over the years. I've tried to list my understanding of the terms you've used below...
XML - you know what XML is, right? The extensible markup language. It's what we had before JSON became the big thing.
JSON - oh, well, JSON is the new big thing. It's a human readable object serialisation format, less verbose than XML. Very popular nowadays. It's the new magic bullet, good for what ails ya, gonna solve all your problems...
JAXB - the "Java Architecture for XML Binding" in the Java ecosystem is the primary mechanism for turning XML data into objects which you can then interact with, and vice versa. It's important to realise that it's an API and not an implementation, so it mostly defines a set of annotations and simple classes / interfaces in the javax.xml.bind package. To do anything useful with JAXB you need an implementation. There's a reference implementation included in the Glassfish application server. Most application servers will have some kind of implementation of JAXB.
Jackson - a library for data binding. It supports both XML and JSON as document formats, and implements the JAXB API. You can use Jackson as your implementation of JAXB, or you can just use the Jackson API directly.
EclipseLink Moxy - an alternative implementation of the JAXB API. Like Jackson, it also has its own API. You can choose to use it, or not. You probably don't want to use both Jackson and Moxy.
Jersey-media-moxy - as you mentioned, Jersey is an implementation of JAX-RS. One aspect of JAX-RS is passing documents around - often XML or JSON. To do that Jersey needs to know what underlying library to use for data-binding or stream processing. So jersey-media-moxy exists as a kind of jersey plugin dependency which you can use to configure Jersey to use Moxy for your object serialisation needs. There's an equivalent package for using jackson called jersey-media-json-jackson.
Jettison - Yet Another serialisation library for converting Java objects to Json and back.
JSON-P - an API for processing JSON either as a stream of events or via data-binding to an object. This API is still in development. You might ask how it is that anybody does json processing without it - the answer is that they either utilise proprietary library APIs (such as Jackson or Moxy) or they use a library which repurposes the JAXB API to work with JSON (Jackson definitely allows this, I'm not sure about Moxy). JSON-P will make it easier to work directly with JSON features, without all the XML-concepts which JAXB brings in.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
My aim is to develop a SOAP web service in Java.
I want to go with the 'contract first approach'.
The obvious steps (in order) are:
Create a WSDL file from scratch
Generate Java classes using wsdl2java
Develop business logic round the generated Java classes
However, I am a little apprehensive about writing a WSDL from scratch (given the complexity).
I just wanted to know if there are any standard tools which are used to author a WSDL file from scratch?
Searching around the web, I realized that you have learn how to author WSDL yourself.
There are no wizard like tools that ask you few simple questions and do it for you.
WSDL is yet another XML schema definition (aka XSD) which defines the web service.
So using any standard IDE like IntelliJ IDEA, Eclipse, NetBeans should do the trick.
If you are apprehensive about authoring the WSDL, it may be because you are not comfortable with the following concepts (as in my case). So pull up your socks and spend some time to understand the following:
XML
XML Namespaces
XML Schema (XSD)
Here are a few resources that may help you write your own WSDL from scratch:
XML Schema : http://www.w3schools.com/schema/
XML Namespaces : http://www.w3schools.com/xml/xml_namespaces.asp
WSDL Structure: http://www.w3schools.com/xml/xml_wsdl.asp
Doing the same search around the web I managed to find only one free tool which may help writing WSDL.
WSDL Editor Plugin for Eclipse
This plugin is part of Eclipse Web Tools Platform Project and gives you full visual support when building WSDL document.
you can also start these process to generate WSDL.
1.) write java class. like
package test.web.service;
import javax.jws.WebMethod;
import javax.jws.WebService;
#WebService
public class WebServiceServer {
#WebMethod
public int addition(int a,int b){
return a+b;
}
}
providing a link : where you can learn soap web servive easily in effective manner
http://javabrains.koushik.org/p/java-ee.html
I'd like to create a Java web application on top of Google AppEngine.
What is the best way to develop a REST jSON API?
Do I have to write from scratch a servlet that manages the jSON handling or there is a library or something like the SOAP support for web services?
No need to write a servlet from scratch, use JAX RS, it is easy and simple
http://tugdualgrall.blogspot.com/2010/02/create-and-deploy-jax-rs-rest-service.html
Try RESTEasy. It has superb docs and there nice examples to be found. It integrates with Jackson which is IMO the best JSON lib for java.
If you use jersey then you should have a look at Genson http://owlike.github.io/genson/.
It is a full databinding+streaming java<>json library. And as a bonus with jersey you only need to have genson in your classpath and voila! Everything shall work without any configuration.
the answer here might be what you're looking for. (Gson should be able to both generate and parse JSON)
After some research I think that using jersey is a good
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I want to test my RESTful applications directly via HTTP and I am looking for tools that can help me with that task. Basically I am looking for an easy wrapper for HTTP requests that can submit e.g. HTML forms or serialized resources as JSON or XML.
It would be great if there is a way to verify if the service is actually following REST architectural guidelines (statelessness, URIs, content negotiation etc.), too.
Being able to use it with JUnit would be a convenient bonus. Do you know about any libraries that could help me with what I want to do (and that are a little more than just a simple http client)?
See if rest-client is of any help.
Edit: Currently I am using Postman - REST Client a google chrome plugin and it's awesome!
I think REST Assured will suite you very well. It's very easy to send requests and to parse XML and JSON responses. E.g. let's say that a GET request to "/lotto" returns JSON:
{
"lotto":{
"lottoId":5,
"winning-numbers":[2,45,34,23,7,5,3],
"winners":[{
"winnerId":23,
"numbers":[2,45,34,23,3,5]
},{
"winnerId":54,
"numbers":[52,3,12,11,18,22]
}]
}
}
You can make the request and validate the response like this:
expect().body("lotto.lottoId", equalTo(5)).when().get("/lotto");
There is also the Jersey Test Framework (http://jersey.java.net/nonav/documentation/latest/user-guide.html#test-framework) but as Johan already mentioned the REST-assured framework I'd also recommend this framework - it has some nice featues like a DSL like syntax, XPath and Schema validation, easy file upload and using Groovy Lambda Expressions to search through returned JSON structures..
I have written two articles..
the first one compares REST-assured and Jersey-Test-Framework (http://www.hascode.com/2011/09/rest-assured-vs-jersey-test-framework-testing-your-restful-web-services/),
the second explores the features of the REST-assured framework against a given REST service (http://www.hascode.com/2011/10/testing-restful-web-services-made-easy-using-the-rest-assured-framework/)
Fiddler is a really useful tool, you can create XML based HTTP Requests with a variety of request verbs like GET,POST,PUT,DELETE and so on.
http://www.fiddler2.com/fiddler2/
Maybe Selenium can be of some help, but surely not entirely.