Web Services in Java

What do you usually use to connect to a Web Service when you are developing a Java project?

There are different API-s that can do the job. From different books and tutorials I have read about: JAX-WS, JAXB, JAXM, JAXR, JAX-RPC, Axis ans so on.

I'm interested in what exactly are you using and how much? Take this as a survey if you wish :)

Asked by: Adelaide375 | Posted: 28-01-2022

Answer 1

To answer your question, we first need to differentiate between the tools you listed.

JAX-WS, JAXB, JAXM, JAXR, JAX-RPC are XML and Web service related APIs while Axis 1 and 2 are implementations of zero, one, or more of these APIs depending on the version.

JAX-B 1 and 2 are XML to object binding APIs, JAX-WS is a WSDL and SOAP based Web service API and the predecessor of JAX-RPC, JAX-M is an older XML messaging API and JAX-R is an abstraction API for interacting with registries such as UDDI and ebXML.

From the Java.net JAX-RPC page:

The JAX-RPC expert group has wide industry participation with Sun Microsystems as the EG lead. The initial specification (JAX-RPC 1.0) was JSR-101 and was released in June 2002. A maintenance release followed in October 2003 providing better integration with JAXB 1.0 as well as better support for doc/literal.

The next version of the spec was renamed from JAX-RPC 2.0 to JAX-WS 2.0 and is being developed as JSR-224; this release will address a number of additional requirements in the area, and will increase the synergy between the JAXB and JAX-WS specifications. You can access the JAX-WS project page here.

Since SOAP stacks have come a long way since JAX-B 1.0 and JAX-RPC 1.0 I recommend staying far away from Axis 1.0 and XFire (which if I recall correctly doesn't even implement JAX-RPC 1). There are numerous SOAP stacks out there that implement the newer APIs (JAX-WS 2.x and JAX-B 2.x).

As others have mentioned, Axis 2, JAX-WS RI, and CXF are all valid choices. These SOAP stacks are far more mature and support many modern WS-* specifications.

A word of caution about the comments regarding using your IDE to auto-generate client code. While I am a big proponent of generating XML data binding code and JAX-WS interfaces from XSDs and WSDLs, respectively, I caution using a built-in wizard in your IDE to perform the auto-generation. If you work on a team with more than one developer or plan to modify the generated code you should consider the maintainability of such an approach.

If you have more than one developer, there will come a time when one of them is using a different version of the auto-generation tool, a different IDE, or has a different configuration in their tool. Additionally, if you auto-generate from a wizard, it is up to the developers to remember how they generated the code in the event that you need to re-generate it in the future. If you change the XSD and don't remember your configuration from the last time you auto-generated, the generated code may not align with the existing code that is already used throughout your program.

If you plan to modify the generated code, make sure that you only ever need to do it once and that from then on you are comfortable maintaining the code by hand or merging the regenerated code with your modifications on a regular basis.

Both of these issues can be avoided by scripting the code generation in your build process. JAX-WS and JAX-B both come with Ant tasks and/or Maven 2 plug-ins that are easy to use in your builds. Take these warnings seriously as I have seen multiple projects suffer through these issues when they needed to modify code that was generated 5 years ago by an employee that had since left the firm.

My final words of caution are to be careful when allowing a tool to auto-generate your Web service interfaces from your WSDLs. The JAX-WS RI WSDL2Java tool likes to place hard-coded paths to the WSDL in the generated interfaces. It is my opinion that you should auto-generate the interfaces once and then remove the hard-coded URLs and QName references to make the interface applicable to all Web services that implement the WSDL Binding that the interface represents and not just the one endpoint that your WSDL describes.

Answered by: Darcy561 | Posted: 01-03-2022

Answer 2

http://cxf.apache.org/ is nice.

Answered by: Joyce842 | Posted: 01-03-2022

Answer 3

you can use, apache axis. This will generate the java stubs automatically if you provide the WSDL. once the stubs are generated its just like calling a normal java class.

Answered by: Freddie618 | Posted: 01-03-2022

Answer 4

Axis proponents here need to be precise.

The Axis 1.x project was abandoned after Axis 1.4 was released in April 2006, over three years ago. We've recently encountered several very critical thread safety bugs in the Axis 1.4 client libraries, including 100% CPU spins and deadlocks. These are well documented (and still unresolved) in the Axis 1.x bug database. Needless to say we are giving up on Axis 1.x (and just using raw Apache HTTP client code).

Axis 2 is an entirely new code base ... perhaps someone else can comment on it.

Based on our experience we'd consider Metro, CXF, hand-coding, and (maybe) Axis 2 for SOAP web services. (We recommend REST-based approaches over SOAP whenever you have a choice, and are using the Restlet framework, which we love)

IMO, you'd be absolutely nuts to go with Axis 1.x

Answered by: Tara492 | Posted: 01-03-2022

Answer 5

Because we have quite heavy investment in Spring, we use Spring-WS with JAXB.

Answered by: Audrey959 | Posted: 01-03-2022

Answer 6

I have used both Axis and Axis2 and find them both very good.

Answered by: Lenny721 | Posted: 01-03-2022

Answer 7

I think the most common use is with Apache Axis2. It's very easy to create services with it and you will find a lot of tutorials.

Answered by: Kirsten484 | Posted: 01-03-2022

Answer 8

I've used both JAX-WS RI and Apache CXF. If you are using Spring then CXF is a very good option. As Phill mentioned, there is Spring-WS as well, but CXF builds upon the JAX-WS spec. If you are not using Spring then I would say that the RI is the way to go, especially since it is bundled with Java 6.

Answered by: Roman126 | Posted: 01-03-2022

Answer 9

For POX+HTTP or RESTful web services, Restlet or a decent HTTP client implementation are completely sufficient.

Answered by: Miller336 | Posted: 01-03-2022

Answer 10

+1 for Apache Axis.

But JAX-WS would also be a good choice.

Answered by: Kellan905 | Posted: 01-03-2022

Similar questions

Java Web Services - Is Axis Necessary?

Is AXIS or CXF necessary for Java web services? Can it be all done via the JDK (1.6)?

java - Why am I unable to generate client side code in web services 'Hello world' example?

Link is: http://people.apache.org/~ruchithf/hw-axis2/. Command line is: javac -extdirs d:\lib\ D:\stub\src\org\apache\ws\axis2\*.java -d d:\clientcode\ The Error is: C:\Program Files\Java\jdk1.6.0\bin>javac -extdirs d:\lib\ D:\stub\src\org\apache \ws\axis2\*.java -d d:\clientcode\ D:\stub\src...

c# - Java and other clients for WCF RESTful Services

I am wanting to expose some data service endpoints for internal application use and am debating on WCF REST as a possible solution. What are my options for other languages/platforms as clients? Keeping in mind that I need to service Java, Python and .Net clients. Essentially, I want to be able to demonstrate a single point of organization data access for multiple clients, and feel that the REST toolkit, especi...

Best way to consume .NET web services in Java

I'm trying to consume some .NET web services using JAX-WS. I have generated the Java classes using the wsimport tool. However, when I try to use these (proprietary, not public) web services in Java, I notice that most of the methods and properties provided by the vendor in their C# examples are not avaiable in the generated classes (despite having not encountered any errors when generating the Java classes from WSDL file)....

java - F5 irule with RESTful services

I'm trying to come up with a rule on our F5 to direct traffic to our Tomcat server appropriately. We are deploying separate WAR files for each RESTful service. So, we would like to have the following URIs as an example: /services/quiz/01234/ /services/user/54321/ Where 'quiz' and 'user' are quiz.war and user.war respectively. We want to direct the traffic at the F5 level for /services/ to be the root and th...

spring - What is the best Java-way to create JSON/XML REST Web services that is similar to WCF?

I'm looking for a best way that is available for Java developers to implement REST services that will be communicating via JSON or XML. I'm looking for production-ready products. I know that Spring 3.0 is coming, but it's not done yet - no luck. Is Jersey the one? My application is hosted by Tomcat, uses Spring, Jettison and XStream. I'd like to use an open-source package that will allow me...

java - What is the best way to write a test case for JERSEY web services?

I have a JAX-RS web service implemented with Jersey library and now I want to test it. In order to do that I'd like to host this service in my test by preinitializing it with mocked services. What is the best way to host such a service and execute the test calls? @Path("/srv") public class MyService { @GET public void action(@Context UriInfo uri) { ... } } @Test public void myTest() { M...

java - What is the best way to write a test case for RESTLET web services?

I have a JAX-RS web service implemented with Restlet library and now I want to test it. In order to do that I'd like to host this service in my test by preinitializing it with mocked services. What is the best way to host such a service and execute the test calls? @Path("/srv") public class MyService { @GET public void action(@Context UriInfo uri) { ... } } @Test public void myTest() { ...

java - Consume Axis2 Web Services in Visual Studio 2008

I'm having a bit of trouble getting Visual Studio to play nicely with my Axis2 web service. The problem is very strange, although not a show stopper. If anything it is just annoying, and I'd really appreciate a way around this. The problem is that when using the web service in C# code, none of the parameters or return values are in their native data types. So instead of just being able to call, for example:

web services - java p2p video library?

is any such library available either commercial or open source?

web services - Soap under Java 1.3 with Axis

I am writing a Java web service for legacy SCO machines (which only have Java 1.3 available). I have been able to get more recently-added XML parsing functions integrated by including the Xerces jar on my classpath. However Java is screaming about not being able to find javax.xml.soap, even though I've got Axis 1.3 and explicitly added axis2-saaj-1.3.jar (which claims to include javax.xml.soap.*) Nonetheless, it te...

Still can't find your answer? Check out these amazing Java communities for help...

Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)