views:

502

answers:

2

This week I had to look into a Java WebService project which was using SOAP packages javax.xml.soap.*.

I have not used this before but the Apache CXF library to create a SOAP webservice.

I have a question on javax.xml.soap.*

Is it better then CXF in terms of performance?

In terms of coding I see CXF is amazing as no need to worry about SOAP API at all and simply by using annotations can create a service in minutes.

Also is MessageFactory and SOAPConnection are threadsafe? I am asking this to save the creation of these objects everytime. If the creation is not a overhead then no problems, but if it is then I want to create them only once. I couldn't find in the javadoc about thread safety.

+2  A: 

javax.xml.soap is a low-level API, CXF is an implementation of that API, one of many implementations. CXF uses javax.xml.soap underneath, as do all of the implementations.

A more meaningful comparison is between JAX-WS implementations, such as JAX-WS-RI and CXF.

skaffman
+3  A: 

Actually, CXF does NOT use javax.xml.soap (SAAJ) underneath unless its required to do so (JAX-WS handlers are present, Provider type things, etc....).

In general, using SAAJ will be slower than CXF since it doesn't allow streaming which CXF would normally do. With SAAJ, the entire SOAP message is in memory as a DOM. That said, if you DO want/need your data as a DOM, it can be a little faster as less processing is needed.

Daniel Kulp