How to get started with java web-services? - java

I am intermediate in java now I am planning to move to java web-services...
How can i get started with web-services?
What are the prerequisites?
Thanks...

To get started with web services in Java, I would recommend to use the Java API for XML Web Services A.K.A. JAX-WS. The reference implementation of this API (JAX-WS RI) is included in Java 6 (since Java 6 update 4) so you don't have anything to install if you are using Java 6u4+. Like the other APIs of Java EE, JAX-WS uses annotations to simplify the development and deployment of web service clients and endpoints. This API supports both Java-first and contract-first approaches (the former begin debatable but, well, this is the easiest way to get started).
You'll find many good tutorials on the NetBeans website, see Getting Started with JAX-WS Web Services or Developing JAX-WS Web Service Clients for example. When it comes to web services, I must say that NetBeans has actually far more better support than Eclipse and would be my recommend IDE. I do not want to go to much into the details (because things will become confusing) so I'd just recommend to use GlassFish for the deployment of your JAX-WS web services, it has everything required included 1.
But please, forget Axis 2 and its horrible deployment model (to be honest, I don't understand why people keep mentioning Axis 2, maybe only because it has been promoted by IBM with its Eclipse support).
You'll find plenty of other resources on Glen Mazza's Weblog, for example the "famous" DoubleIt tutorial.
If you want to go further, have a loot at this great online Web Services Course from JavaPassion (great resources, as always).
1 If really you want to know, the web services stack in GlassFish is called Metro. Metro includes JAX-WS RI (the reference implementation of JAX-WS) and WSIT (that provides an implementation of others WS-* standards for Secure, Reliable, Transactional and Interoperable Web services). Another implementation of JAX-WS is Apache CXF. You may find all these terms in the literature. For now, I'd stick with JAX-WS RI with GlassFish as container and NetBeans as IDE.

This is a must if you plan to provide (SOAP based) webservices or want to get a feeling on how to consume services: soapUI
And I am quite happy with eclipse's web tools platform when it comes to designing xml schemas and wsdl files.
One of the most common java libraries is apache axis2. Pretty sure, they have a lot of documentation and tutorials on their pages.

Just start with apache tomcat and run a web-application in it with a small servlet or JSP, and then once you master a bit how to create web applications for tomcat, go and check axis2, this is a web application that gets installed in tomcat, then you will be able to run your own web services in axis2.
If you one something more advanced you could go and check EJB3 and create a stateless session bean that will work as a web service... but this is more advanced and is much more difficult to set up an EJB3 project, I advise starting with tomcat/axis2.
good luck.

Related

Invoking .Net webservices from Java

I have a web service created in .Net and I am interested in invoking this web service in my java application.
What set of libraries would be the best suited to do this? I've looked into GlassFish, but have been unable to find anything examples of this being used to invoke a .Net web service, only creating the Java side web service.
I have some experience using wsif, but it appears to be rather outdated and would like to use something more current if possible.
Check out those links:
Your question
WebServices in java,
this tutorial uses JAX-WS 2.0
A simpler approach to what you want
The standard Web services stack in Java is JAX-WS, which is the one included in Glassfish, and it can be downloaded from http://jax-ws.java.net/. There are other JAX-WS compliant implementations out there, but not necessarily using JAXB (the one used by JAX-WS).
Use the JAX-WS wsimport utility to generate the Java client side from a WSDL.

Developing a web service

Is there any tutorial on web for developing a simple web service(Spring framework)from scratch in ibm rad 7.5?
See Which framework is better CXF or Spring-WS?
Tutorials:
Spring WS
Apache CFX
There are a lot of tutorials on the Spring site for Spring Web Services, especially since they just came out with v 2.0 today. I'm not aware of any that deal with a specific IDE environment, unless its maybe the new Spring flavor of Eclipse they've released, STS. One thing to keep in mind is that Spring web services are "contract first", so you have to create all your XML schemas for your service data structures, vs the code first that a lot of us are used to using Jax-WS, though there are many that say that contract first is THE way to go, for a lot of reasons.
YMMV

Easy way to generate web service clients in Java WITHOUT using Axis

I've always used the web service generation in Eclipse WTP to build my web service clients due to it's relative easy of use.
However, in the last couple years, as I've learned more about it I've seen the error of my ways.
I've read that one should use one of the plethora of other java web service client platforms such as CXF, Metro, etc.
At this point, I don't particularly care which platform I use - so long as it is not Axis.
My question is - the WTP tooling makes it easy to generate web service clients in java. Are there any similar tools, scripts, programs or tutorials that are of similar ease of use?
I don't really have time to learn all the intricacies of SOAP, RPC, etc. so please keep in mind that I'm not really trying to be lazy so much as I am pragmatic.
Thanks in advance.
SoapUI can generate the soap clients for many multiple java soap stacks like axis 1 & 2, xfire, GStep, JAX-WS, JAX-RPC, JBoss WS, Oracle Proxy, cxf, .Net, GStep. Here is the tutorial on how to do it.

Jetty vs CXF / Which one to choose?

I am fairly new to the Java world and pretty overwhelmed by the beauty of choice between dozens of libraries doing more or less the same thing, or not.
So with Jetty and CXF. I am looking for a web services stack that has built-in support for a wide range of transports and protocols.
I was under the impression that CXF is the more recent project and would be the preferred choice for new software projects. Especially when it comes to applications that have to talk a variety of different protocols and standards like WS-*.
Can you give your opinion on how those frameworks differ from each other?
Which one has broader support for different protocols and standards?
Which one would you prefer regarding its design e.g. how well they hide transport, authentication, authorization, serialization aspects from application logic?
Any kind of answer very welcome!
Cheers,
Alex
Jetty is a web server and servlet container. CXF is a library for web services. If you want to serve out content like is done with a web server, choose Jetty. If you need to connect to or provide web services, choose CXF. I'm not sure there's any blurred area between the two.
There is a misunderstanding here, Jetty and CXF are like apples and oranges, it doesn't make sense to compare them. One is a light servlet engine, the other one is a web services stack.
If you're looking for a web services stack (which is my understanding), consider JAX-WS RI or CXF if you are looking for a JAX-WS compliant stack (both support contract-first or java-first), or SpringWS ("only" contract-first), or maybe Axis2 (I don't like it personally it because of its development and deployment model and its performances).
If you don't need fancy WS-* stuff, I'd suggest to use JAX-WS RI which is included in Java 6 and is compliant with the WS-I Basic Profile 1.1 (so it covers a decent bunch of WS-* standards). If you need more advanced things (like WS-SecureConversation, WS-SecurityPolicy, WS-ReliableMessaging, WS-Trust, WS-AtomicTransactions/Coordination, WS-MetadataExchange, SOAP over TCP which are provided by WSIT/Tango), consider using Metro (Metro = JAX-WS RI + WSIT/Tango).
(EDIT: Answering a comment from the OP about WS-SecureConversation support.
Actually, I think that the stack that supports the most WS-* standards is Metro. You might want to check Apache Axis2, CXF and Sun JAX-WS RI in comparison for more details. But, it is very unlikely that you'll need all of them and things might have slightly changed since the article has been published. So CXF might indeed be an alternative. For example, regarding WS-SecureConversation, CXF does support it too according to its documentation but only with "wsdl-first" projects. Without more details about what you're going to do, it's hard to give you a more accurate answer about which one is the best for you.)
Jetty is a server(a servlet container), so is Tomcat and few others. Jetty is decent, Tomcat has been around for a while and has more documentation and tutorials.
CXF looks like an interesting choice. I've only use directly implementations and CXF was fairly new, I think it's the continuation of XFire project.
CXF looks like a wise choice. When in doubt, I would say go with standards and frameworks built upon them. I would say go through the documentation and for complicated matters, you might want to subscribe to some mailing lists.

Java SOAP Server that can be deployed in Tomcat, JBoss, Geronimo, etc. etc. etc

I'm hoping to create a Java SOAP server which I can deploy in Tomcat, or in JBoss, or in Geronimo, or in XYZ, etc. etc. etc.
Bottom line, it should have the least dependencies possible. I'm trying to avoid libraries outside of what's included in a standard java distro because of licensing/packaging/reusability issues.
Can any provide a link to where I should start looking, or some example code?
Java 1.6 introduced the possibility to create standard SOAP webservices with the standard JDK.
There are many examples on the web, for example http://weblogs.java.net/blog/2006/12/12/webservices-jdk-6
IDEs like NetBeans also call the necessary tools (apt) automatically which makes it very easy to get started.
However I did not research how well this will work across all available containers.
Apache Axis2 (http://ws.apache.org/axis2/) should provide what you're looking for, or JAX-WS (https://jax-ws.dev.java.net/) if you want more lightweight.
Wow.
http://www.w3.org/TR/soap/
There's the standard. You will be spending a lot of time on this project. You'll need to also check out the HTTP and XML specs to build those components.
Ignoring XFire and Axis2 is an very very expensive choice...
I recently used Metro 1.4 for this (an open source glassfish component) which implements the standard approach for web services.
Drop in the jars in a Java 5 web container, annotate your class and method with standard #tags, and let Metro do the rest.
I have been very pleased with performance in a Jetty container.
If you use Spring web service module you don't need Axis or XFire. I think it's a good way to go if you're already using Spring.

Categories