Java Webservice Client (Best way) - java

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...

Related

How to go about creating SOAP webservice in Java

I did some Core Java programming a decade back. Now I've got a project to create SOAP website.
I've a Windows machine setup on Amazon with Eclipse installed on it.
I thought of buying this book: http://shop.oreilly.com/product/9780596001759.do but it was released in 2002 and it's contents may be obsolete.
I could not find any other stuff about how to go about creating SOAP webservice in Java.
Please HELP!
So I want to know step by step procedure, setting up the IDE + libraries etc.
Read some tutorial from internet for creating jax-ws webservice.
If you want to read some books I would recommend these two books :
1.Java Web Services: Up and Running
2.Apache CXF Web Service Development
You can use axis2 for creating your webservices. Axis2 Web Service using Eclipse will give you some help about creating one.
The standard way is to use JaxWS, which is a part of Java 6 and later. The approach varies depending if you use the "Java classes first" or "Contract first" approach.
I always use contract first:
Write the WSDL and any supporting XSDs that might be required
Create the Java classes using wsimport (command line or as a Maven plugin)
Add the business logic to the generated class
There are multiple tutorials on the web. Search on JaxWS and wsimport.
The integration with Java even allows you to publish a web service from a triial command line program.

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.

Web services clients in 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.

How to get started with java web-services?

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.

Categories