WSDL to java conversion - java

I want to convert WSDL file into java classes file.Suggest me the package used for it. I found one that is axis 2.0 .But i want to more packages used to do this job. please suggest me any article where i can find about the comparison related to different-2 packages for their performance.
Thanks

Use wsimport.

I worked on two packages axis 2 and cxf .I used WSDL2JAVA tool for conversion and find that Axis2 is structured modularly, has many features and can be used as an application server for Web Services. A special feature of Axis2 is the support of exchangeable binding frameworks, for example XMLBeans. Axis2 together with the XMLBeans framework is well suited for Web Services which are using very complex schema definitions. The disadvantages of Axis2 are its complexity as well as the insufficient JAX-WS support. Therefore anyone who wants to work with JAX-WS should choose Apache CXF or the reference implementation.
Those who prefer a seamless integration with the Spring framework are well advised with Apache CXF. Furthermore CXF is slim and easy to use. CXF is the tool of choice if a SOAP engine has to be embedded into existing software.
Thanks.

Related

Which feature make one to use Spring WS over JAX-WS

For SOAP Based Web Services, why one should choose Spring WS over JAX-WS.
I had gone through some article even Spring WS doc feature but still I am not clear.
If I need to convince someone to use Spring WS I can't.
So I want the difference in simple terms that any Web Service Developer can understand.
Thanks in advance.
I am not going into the details of JAX-WS versus Spring-WS.
You might want to refer to the link here for details on that and google it.
From my personal experience :
Spring-WS Advantages over JaxWS
You want to use a databinding other than JAXB (JibX, Castor or
others)
You want extreme fine grained control on the endpoint mapping strategy
You are choosing a WSDL first approach (though many argue that JAXWS also supports a WSDL first approach, it is generally accepted to be more flexible in spring-ws)
JaxWS over SpringWS
You want to go for a java first approach
You want to make your code flexible (since JAXWS is a specification you can have multiple implementations)
You want to use other annotation driven development of JAX-WS

Generating client stubs from WSDL

I am starting on a new project with commercial vendor. I need to write an integration module in our application to consume commercial vendor's web service. So, WSDL is not controlled by us.
I think the general approach is to do a "Contract First" development and generate stubs from the WSDL file. I would like to know what technologies are available to do this? I would really like the simplest approach that works. We use Maven 3.0.3 and Spring 3.0.5 extensively. Can I use Spring WebServiceTemplate?
Please let me know if the question isn't clear or additional details are needed.
Thanks,
Tapasvi
You can generate the java stubs with the maven plugin for JAX-WS. Then you can use the stubs in spring to expose them as a webservice. Luckily, it's quite simple :).
Just a suggestion, don't re-generate the stubs every time you build the project, as (obviously) you won't be able to add any code to the stubs, which is sometimes very useful. I made this mistake long time ago and it was quite painful, because I had to put code in places where it didn't belong. In the last few years I used a maven profile to generate the stubs on demand and then I merged them "manually" to add the extra code. Of course, this is only viable if the WSDL doesn't change very often.
I have used axis and the easiest way to do is to run the utility wsdl2java and pass the location of the webservice along with the ?wdsl option.
I know lots of IDE's these days will allow to generate you stubs from within. MyeclipseIDE has an option to ingest an WSDL so does intelliJ. I think the safer approach is to use wsdl. Also if you are using jax-ws you can try
wsimport -keep -verbose location to wsdl
JAX-WS is included in the standard Java 6 distribution making it very simple to use.
Generate stubs with wsimport in the JDK (remember to enable as many warnings as possible, as you want to know anything that may cause problems).

How to use wsdl2java created Java code?

I have a WSDL file using which I have generated server side classes in JAVA using axis2-eclipse-codegen-plugin-1.5.4 and Axis 2 Service plugin. The classes are created but I don't know how to use those classes and I cann't figure out which from all those classes is the main class. It has generated many other methods which I m unable to understand.
Now , I have to modify those classes for so that the service, when published, can send dummy data to client(I have to enter business logic). I am unable to do so. Can any body help/ any tutorials which can help.
You can start from this Axis2 tutorials and articles
If your setup will support it, starting with ejb3, writing basic beans and letting the server generate the wsdl on the fly might be easier. I've done this with glassfish3 and it worked really well.
Check out this tutorial: Developing Web Services Using Apache Axis2 Eclipse Plugins. It is using an older version of the Axis2 Eclipse Plugin (1.3 when you are using 1.5.4), but hopefully the same steps apply, or you can figure them out based on the old tutorial.

What is the best Java OXM library?

Even though I've been a developer for awhile I've been lucky enough to have avoided doing much work with XML. So now I've got a project where I've got to interact with some web services, and would like to use some kind of Object-to-XML Mapping solution.
The only one I'm aware of is JAXB. Is that the best to go with? Are there any other recommendations?
One catch - I'm stuck using Java 1.4, so I can't do anything with annotations.
JAXB is the best choice:
Public API included in Java SE 6
Binding layer for JAX-WS (Web Services)
Binding layer for JAX-RS (Rest)
Can preserve XML Infoset
Multiple implementations: Metro, MOXy, JaxMe, etc
EclipseLink JAXB (MOXy) is the best implementation:
MOXy is a JAXB implementation with Extensions
MOXy has an external configuration file (based on JAXB annotations with extensions):
http://bdoughan.blogspot.com/2010/12/extending-jaxb-representing-annotations.html
http://wiki.eclipse.org/EclipseLink/Examples/MOXy/EclipseLink-OXM.XML
Has XPath based mapping, for deep mapping:
http://bdoughan.blogspot.com/2010/07/xpath-based-mapping.html
http://bdoughan.blogspot.com/2011/03/map-to-element-based-on-attribute-value.html
http://bdoughan.blogspot.com/2010/09/xpath-based-mapping-geocode-example.html
Designed to handle ORM mapped objects, including support for bidirectional relationships:
http://wiki.eclipse.org/EclipseLink/Examples/MOXy/JPA
http://bdoughan.blogspot.com/2010/07/jpa-entities-to-xml-bidirectional.html
If you're calling a web-service with a WSDL, JAXB is absolutely the best option. Take a look at wsimport, and you're be up and running in 10 minutes.
I don't think JAXB 2.0 will be possible on Java 1.4. You may need to use Axis instead:
java -cp axis-1.4.jar;commons-logging-1.1.jar;commons-discovery-0.2.jar;jaxrpc-1.1.jar;saaj-1.1.jar;wsdl4j-1.4.jar;activation-1.1.jar;mail-1.4.jar org.apache.axis.wsdl.WSDL2Java http://someurl?WSDL
This will generate similar stubs to JAXB.
If you don't have a WSDL or XSD, you can always generate one.
There's XStream. I seem to remember I used that ages ago, and it was fine. Can't say I have enough experience to recommend it for or against, but it's worth checking out just as an alternative.
JIBX - known for performance
JAXB2 - Ease of use
Castor - Ease of use
others -
XMLBean,
Xstream

How to create documented WSDL using XFire

I use XFire to create a webservice wrapper around my application. XFire provides the webservice interface and WSDL at runtime (or creates them at compile time, don't know exactly).
Many of our customers don't know webservices very well and additionally they simply don't read any external documentation like Javadoc. I know that it's possible to add documentation (for parameters and methods) directly to the WSDL file.
I thought about Annotations or Aegis XML files but I don't know how... Do you know a way?
Edit: I just found this JIRA issue but the last activity was 2006. Any ideas?
XFire is slowly headed for /dev/null. Use CXF instead. In other words, XFire is being deprecated in favor of CXF - it's pretty much the same developers.
Since you use the Java-first approach, I suggest you generate you WSDL once and for all with CXF's java2wsdl tool, then you put your documentation in that and tell CXF to use that documented WSDL instead of letting CXF generate its own (undocumented) WSDL at runtime/deploy-time.
This page has pretty much everything you need to know about creating a web service in CXF.
And my last hint regarding CXF - use Aegis for data binding instead of JAXB. It doesn't work for complex POJO.
In my experience we have no problem with complex POJO and JAXB, the only problem is that the code starts to be cluttered with JAXBElements. On the other hand, Aegis documentation is pretty sparse and not well-maintained with relation to CXF.
Let's me add my two cents regarding XFire. We had very serious issue with XFie under JDK6 (both Tomcat 6.0 and 5.5).Please take a glance at that issue. In our case XFire with 4+ web services under JDK6 leads to hanging application servers (thread deadlocks etc.). It's interesting, but under JDK5 everything was OK.
And I completely agree with Christian Vest regarding migration to CXF from XFire. It has sense in many cases e.g. ESB Mule 2 doesn't support native XFire connectors anymore (see also).
And I wish to add that migration from XFire to CXF is not straitforward way (e.g. CXF has jar dependences that conflict with some hibernate releases see also), but it's doable. In our case we did it for couple days without code correction (Spring only configuration).
And my last hint regarding CXF - use Aegis for data binding instead of JAXB. It doesn't work for complex POJO.

Categories