Web services clients in Java - java

I'd like you to list all the solutions available to generate web-service clients in Java platform.
I need to extract the structured information from the web-service to work with.
What do we have in the box? Preferably available as Eclipse plugins.
Axis2
JBossTools
Apache CXF
What else ?
The problem here is that most tools do not work with web-services I need to consume.
Apache CXF does not generate the client.
JBoss only partially does the job.
I would like to try something and find what really works with particular web services.

java.sun.com/webservices/.../wsit/.../Examples_glassfish6.html
this is for creating web services

No one gave a clear answer yet.
I got one advice: always try different versions of a framework, and try the latest.
It may sometimes be the key answer.

Related

How to create Web Services in Java (with Eclipse)

I am really really having hard time to create simple "Hello World" Web Service in Java. If you exclude several mobile Android mobile apps I have done, I am pretty new to Java environment.
First I tried Axis2 and that simply doesn't work out of the box. Fresh installation of Eclipse, Tomcat 6.0 and Axis2. Tried sample test app and it failed miserably. You can read about it here. My conclusion is that Axis2 simply doesn't work (maybe it used to work). I will try to go back to install older versions, maybe one will magically start working. I have to modify some old project at work that was using Axis2, so that's why I have to stick with it. I would hate to have to migrate to some other tool.
Then I ran on Oracle article Getting Started with JAX-RPC and I was thinking, cool, let's try that. Well, I just managed to get pissed off. After getting half way through the article and trying to write some simple test web service I realized that their code examples are poorly written. Missing brackets, wrong references, missing explanations, etc...
First of all, an interface should extend not implement. Am I right?
public interface SunRegPort implements java.rmi.Remote {
Also, this doesn't exist:
import java.xml.rpc.server.ServiceLifecycle;
But this does:
import javax.xml.rpc.server.ServiceLifecycle;
Well, I don't feel competent to criticize too much (cause of my level of knowledge about this subject of course), but after all I am suspicious that this article is complete JUNK and therefore I am not able to follow it.
Please somebody tell me that I am wrong and if anybody has some advice or link to some How-To page that talks about web services, I would appreciate.
Thanks.
The terminology Web Services is pretty vague. In Java, the modern and reasonably easy way to do this is by annotating classes.
I would recommend that first, you decide whether you want to implement:
SOAP Web Services -> look at JAX-WS
REST Web Services -> look at JAX-RS
Once you have chosen the "type" of Web Services, choose the library that implements the specification.
The Wikipedia entries list a few of these implementations. Apache CXF (complete but a beast), Jersey (popular) and Restlet are very common choices. I personally like the JBoss implementations as well for JAX-WS.
For JAX-WS with Apache CXF, here is a quick start tutorial that looks pretty good (untested)
For JAX-RS with Jersey, try this
Unless you have strong reasons to do otherwise (for instance you need to call an existing system), use REST which is simpler and leaner.
I would recommend you to check out the CXF project by apache. It's quite easy to use and should help you to set up a webservice.
There is a nice guide to Hello world set up.
http://cxf.apache.org/docs/a-simple-jax-ws-service.html
If you're still interested in giving Tomcat a shot, here is a tutorial on youtube of making a very basic "Hello world" example using Eclipse. It leaves a lot to learn; but it looks like it will at least get you started.
FYI, the version of Eclipse used is slightly outdated. So some of the menu options may not be exactly the same:
http://www.youtube.com/watch?v=EOkN5IPoJVs
Also, the meaning of "Web Service" can be subjective. So, to be specific; this just shows you how to get a basic HTTP endpoint started on your local machine.
If you are not tied to Eclipse, give NetBeans a shot. I think it's much better for Web Services in Java.
Web Services are most widely implemented examples of Service Oriented Architecture (SOA). A service contract is defined with the help of SOAP and Web Service Definition Language (WSDL) and that is published for other applications to use.
In this article we will see how we can create web service and web service client in java.
http://www.opencodez.com/java/how-to-build-and-deploy-web-service-and-client-in-java.htm

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.

Why is there no easy way to consume web services in Java?

I've been doing a lot of work exploring different methods to consume (.NET) web services in Java clients. It seems that this area is a black hole in Java. The easiest way that I have found is to use Apache Axis2 wsdl2java to generate the source files. But still, this requires some work to integrate Apache into my existing web applications.
I'm surprised that there is no easier way. Why is that?
Because there is. The required functionality for SOAP clients are included in the standard API library. You can use the wsimport tool (located in the bin directory of your JDK installation) to generate client classes from a specified WSDL.
I've not used metro, but it sounds like it integrates with JAXB2.0 well and might be worth taking a look at. I noticed a metro vs axis2 comparison which might be interesting if you are familiar with axis2 already.
for quick and dirty stuff the apache commons httpclient + jaxb works well.

Java Webservice Client (Best way)

I have a third party WSDL, I need to write code in Java for a web service client to invoke the operations in the third party WSDL. Right now, I have generated the client stub using the WSDL2JAVA tool from Axis and used the XMLbeans for data binding.
What is the best approach to do this JAVA?
I read about SAAJ, looks like that will be more granular level of approach?
Is there any other way than using the WSDL2Java tool, to generate the code. Maybe wsimport in another option. What are the pros and cons?
Can someone send the links for some good tutorials on these topics?
What are the options we need to use while generating the code using the WSDL2Java?
I used some of the basic things initially. Now I have these options
C:\axis2-1.5.1\bin>wsdl2java -uri mywsdlurl -o client -p somepackage -d xmlbeans -s -t -ssi
What is the best approach to do this JAVA?
I would personally NOT use Axis 2, even for client side development only. Here is why I stay away from it:
I don't like its architecture and hate its counter productive deployment model.
I find it to be low quality project.
I don't like its performances (see this benchmark against JAX-WS RI).
It's always a nightmare to setup dependencies (I use Maven and I always have to fight with the gazillion of dependencies) (see #2)
Axis sucked big time and Axis2 isn't better. No, this is not a personal opinion, there is a consensus.
I suffered once, never again.
The only reason Axis is still around is IMO because it's used in Eclipse since ages. Thanks god, this has been fixed in Eclipse Helios and I hope Axis2 will finally die. There are just much better stacks.
I read about SAAJ, looks like that will be more granular level of approach?
To do what?
Is there any other way than using the WSDL2Java tool, to generate the code. Maybe wsimport in another option. What are the pros and cons?
Yes! Prefer a JAX-WS stack like CXF or JAX-WS RI (you might also read about Metro, Metro = JAX-WS RI + WSIT), they are just more elegant, simpler, easier to use. In your case, I would just use JAX-WS RI which is included in Java 6 and thus wsimport.
Can someone send the links for some good tutorials on these topics?
That's another pro, there are plenty of (good quality) tutorials for JAX-WS, see for example:
Developing JAX-WS Web Service Clients (start here)
Introducing JAX-WS 2.0 With the Java SE 6 Platform, Part 1
Creating a Simple Web Service and Client with JAX-WS
Creating a SOAP client with either Apache CXF or GlassFish Metro (Glen Mazza's blog is a great resources)
What are the options we need to use while generating the code using the WSDL2Java?
No options, use wsimport :)
See also
Elad’s Adventures in Java WebServiceLand
Axis2: Why bother? on the BileBlog (be prepared for the bile) - you'll have to stop the redirect.
Related questions
What is the best java webservice framework?
Spring-ws or Axis2 or Something else for “Contract-First” approach to WS
I have had good success using Spring WS for the client end of a web service app - see http://static.springsource.org/spring-ws/sites/1.5/reference/html/client.html
My project uses a combination of:
XMLBeans (generated from a simple Maven job using the xmlbeans-maven-plugin)
Spring WS - using marshalSendAndReceive() reduces the code down to one line for sending and receiving
some Dozer - mapping the complex XMLBeans to simple beans for the client GUI
You can find some resources related to developing web services client using Apache axis2 here.
http://today.java.net/pub/a/today/2006/12/13/invoking-web-services-using-apache-axis2.html
Below posts gives good explanations about developing web services using Apache axis2.
http://www.ibm.com/developerworks/opensource/library/ws-webaxis1/
http://wso2.org/library/136
Some ideas in the following answer:
Steps in creating a web service using Axis2 - The client code
Gives an example of a Groovy client invoking the ADB classes generated from the WSDL.
There are lots of web service frameworks out there...

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