I am new to web services and below I am sharing my understanding so far by reading on net:
Apache Axis and Apache CXF - are web services frameworks used to develop Java web services.
JAX-RS - Java API to develop Restful web services.
JAX-WS - Java API to develop SOAP web services.
Is the above correct? Or if you want to add something to it.
In my project, I am going to use web services with Spring framework.I am told that project will have both SOAP and RESTful web services.I am very much new to this.
Can somebody please guide me in this regard by sharing some valuable information or any good link which will make me understand better?
Your statements are correct, but it's not clear whether you've understood one crucial fact: CXF and Axis are both implementations of the JAX-WS standard. CXF additionally implements JAX-RS, and there are some libraries that only implement JAX-RS, such as Jersey (Oracle's reference implementation) and RESTEasy from JBoss.
For your project, the big question is whether you will only consume those webservices, or also publish them. If you need to publish a webservice, you'll have to include the entire implementation library and learn to use it. If you only consume the services, you'll just need some generated client and data binding classes.
Another question is whether your RESTful services will talk XML or JSON (SOAP always uses XML), as you'll need a parser or binding framework for JSON (JAX-B for XML is included in recent JDKs).
Related
Why is JAX-WS described as one of the frontends for Apache CXF?
http://cxf.apache.org/docs/frontends.html
I only understand JAX-WS to be an Java api for creating web services.
In this case, frontend is not a GUI frontend rather the frontend that exposes JAVA APIs as a web service (hence, frontend). As described in the link you mentioned, there are different "frontend"(s) or rather modes of exposing and/or consuming the webservices you develop. JAX-WS is for SOAP, JAX-RS for REST and JavaScript services/client.
I am in the process of writing a JSON based web service. The service will accept two types of requests: commands (e.g. createOrder) and queries (e.g. getOrders). Each request needs to send user credentials (username/password) for authentication (perhaps in HTTP headers). The service needs to be implemented in Java.
Which frameworks would you recommend for this use case? The very basic stack that I am thinking of is servlets backed by a JSON framework like Jackson. Are they any other frameworks that you would recommend and why? There is no need or desire to make the service RESTful, however smooth integration with Java EE 6 or Spring would be a plus.
Thanks in advance for your time.
Can I then interest you in RESTful Web Services (which is a JAX-RS API)? A library that implements JAX-RS is Jersey, Apache CXF, which is suited to allow JSON Web Service.
A related StackOverflow Post which shows REST clients that conforms to JAX-RS.
You should take a look at spring mvc and read this blog post which cover using spring mvc for restful WS.
Play! Framework would definitely fit your bill. It is not servlet-based but fulfills all of your requirements. Plus development with Play is very fast, you can get a prototype up and running in no time.
I personally use Apache CXF, with JAX-RS and jackson libraries. They are easy to implement and integration is dead easy. JAX-RS is a java standard, Jackson library is fast and handles circular references and Apache CXF needs only a couple of lines of configuration to setup and start running. Go for it!
An Open-Source Services Framework From Apache
-CXF has been designed to provide a pluggable architecture that supports not only XML but also non-XML type bindings, such as JSON and CORBA, in combination with any type of transport.
-Java EE integration: deploy services in Java EE application servers such as Apache Geronimo, JOnAS, Redhat JBoss, OC4J, Oracle WebLogic, and IBM WebSphere
-Standalone Java client/server
I am not much aware about the details as to which web servers support Web services written in Java.
Would Like to know the following three things:
1) What is required to have support for Web Services : Only Servlet Container or An Application Server + Web container?
2) Would like to know that do all Web Server supporting web development in Java support Web Services?
3) How to identify whether a particular server supports Web Services or not?
Thanking you in advance.
Your question is somewhat unclear. The term web service is applied to anything from a REST style API to SOAP based services to JSON based, etc etc. Wikipedia says an equivalent is a Web API, and an API can be pretty much anything.
So to answer your question. A servlet container is enough to support most common types of web services, it doesn't require an application server. Take a look at Apache CXF, which is a framework catering for a lot of web services styles (notably SOAP and REST).
Apache CXF is a rather large framework, and can take some time to get your head around. If you need something simpler, you may be better off looking at some object serialization frameworks and implement the servlets yourself (this is what I do mostly). To serialize to XML, use out-of-the box Java JAXB annotations. To serialize to JSON, use Jackson.
Assuming you're talking about SOAP WS-* web services via JAX-WS.
Java EE 5+ stipulates support for JAX-WS compatible web services within the container, both at the Web App level, and at the EJB level. So, any full boat, modern, App Server will have JAX-WS support built in.
Servlet 2.x and 3.0 do not have a requirement to support JAX-WS at the container level, but all of the major implementation of JAX-WS can be deployed within a WAR in a modern Servlet container (like Tomcat).
Java EE 6 offers a Web Profile, but the Web Profile does not include JAX-WS. Java EE 6 Full Profile includes both JAX-WS (SOAP, WS-* web services), and JAX-RS (for HTTP and more RESTful web services).
So.
If you bundle your own implementation, all of the containers should accommodate you. If you want it built it to the container, you'll need a full Java EE 5 or Java EE 6 App Server.
I have a requirement to create RESTful web service.
I have narrowed down on 'Restlet' for the web service implementation.
Can someone tell me the clear pro's and con's of using Restlet and if there are any better alternatives.
thanks in advance
Restlet has an extensive list of extensions for Spring, WADL, XML, JSON as well and many more, including an extension for JAX-RS API.
It is also the sole framework available in six consistent editions:
Java SE
Java EE
Google Web Toolkit
Google AppEngine
Android
OSGi Environments
Its main benefits are:
fully symmetric client and server API when JAX-RS was designed for server-side processing
connectors for other protocols than HTTP (mapping to HTTP semantics) when JAX-RS is HTTP only
much broader feature scope including full URI routing control via the Restlet API (but can integrate with Servlet if needed)
full provision for NIO support
The JAX-RS API can be a good choice if you are restricted to JCP approved APIs (then don't use Spring or any extension of the JAX-RS projects like Jersey and RESTeasy!), but otherwise Restlet is the most mature framework (initially released in 2005) and will give you, in its 2.0 version, all the benefits of annotations combined with a powerful and extensible class-oriented framework.
For a longer list of features, please check this page.
Best regards,
Jerome Louvel
Restlet ~ Founder and Lead developer ~ http://www.restlet.org
For a comparison of JAX-RS frameworks see JAX-RS Frameworks
Jersey API can be used to implement RESTful Web services.
http://jersey.java.net/
Other than RESTful Web services, Jersey also provide many other features.
Some more useful links regarding available REST frameworks and their comparisons:
A Comparison of JAX-RS Implementations
rest-introduction
tilkov-rest-doubts
Rest anti-patterns
JAX-RS Vendor Comparisons - Part I
Apache Cocoon is a very good solution to implementing a RESTfull Web Services.
Can someone point me a good step-by-step tutorial to consuming an already running web service in java?
PS: I tried creating the classes with wsconsume, but it cries with
[ERROR] rpc/encoded wsdls are not supported in JAXWS 2.0. (my web service is rpc/encoded)
If I can consume web services entirely by hand (using no wizards), and understand how is it working, then I'll be happy.
Thanks!
Update: I have found out that rpc web services are not consumed using jbossws, but jboss-jaxrpc, which implements the JAX-RPC specification. I've found a guide for JAX-RPC here, but I'm still looking for other guides that could help.
Apache CXF is the easiest way to get webservices running. Specifically look at the Simple Frontend. The simple front end uses reflection to convert the method/data types to a webservice. It doesn't get much easier than that.
CXF is pretty stable, but does not include all the WS specifications (WS-Eventing for example).
How about the JBossWS website? The details on the client side wsconsume tool are probally what you will look at first.
If you have the WSDL and XSD files, you can use the Axis web-services library to create Java classes that will interact with the services they describe. From the stand-point of this library, you are creating a client application.
You can also consume web services with Spring WS.