Java API for XML Web Services (JAX-WS) FAQs
Index
-
Getting Started
- What are the different versions of JAX-WS ?
- Does JAX-WS support JAX-RPC 1.X ?
- What is the difference between JAX-RPC and JAX-WS ?
- Can a JAX-WS and a JAX-RPC based service co-exist ?
- How do I find out which version of the JAX-WS RI I'm using ?
- Is it downloadable from maven repository ?
JAX-WS 2.0
JAX-WS 2.1
- How do I run JAX-WS 2.1 with Java SE 5 and Java SE 6 ?
- What are the new features in 2.1 release ?
- If the WSDL binding adds additional headers, how can I add them to request ?
- Does it support spring framework ?
Miscellaneous
- Do I have to specify all attributes for annotations (like @WebService, @WebServiceRef etc)?
- Does Java EE 5 platform support JAX-WS?
- Is the stand alone JAX-WS-based service developed and deployed on Servlet container is portable on all Java EE 5 based platforms?
- How do I make my stand alone JAX-WS service portable across JavaEE5 platforms ?
- Why does JAX-WS runtime fetch WSDL? Aren't the annotations on the genarted portable artifacts enough for runtime to work correctly ?
- How can I change the address dynamically for an Web Service request ?
- How do I do basic authentication in JAX-WS ?
Q. What are the different versions of JAX-WS ?
| JAX-WS RI 2.0 | RI for JSR-224. Java SE 6, Java EE 5 and Glassfish 9.0 also include JAX-WS 2.0 implementation |
| JAX-WS RI 2.0.1 | Intermediate version used for rearchitecting JAX-WS 2.0, and resulted into JAX-WS 2.1. Not supported anymore. |
| JAX-WS RI 2.1 | RI for JSR-224 MR. The 2.1 code base is completely rearchitected so that it provides extensibility, performance, and various other improvements. This provides the foundation for the Web Services Interoperability Technology. Glassfish 9.1 also includes JAX-WS 2.1 implementation |
Q. Does JAX-WS 2.0 support JAX-RPC 1.X?
No. Although, JAX-WS's roots come from JAX-RPC, JAX-WS is a completely different component than JAX-RPC. To read more on why JAX-WS diverged from JAX-RPC read this blog
Q. What is the difference between JAX-RPC and JAX-WS ?One of the main difference between JAX-RPC and JAX-WS is the programming model. A JAX-WS based service uses annotations (such @WebService) to declare webservice endpoints. Use of these annotations obviates the need for deployment descriptors. With JAX-WS, you can have a webservice deployed on a Java EE compliant application server without a single deployment descriptor. Apart from these, other additional features (such asynchronous callbacks etc) are also present. Refer to the JAX-WS specification for more information.
Q. Can a JAX-WS and a JAX-RPC based service co-exist?Yes.
Q. Is it downloadable from maven repository ?
Yes from https://maven.java.net/content/repositories/releases/com/sun/xml/ws
Q. How do I find out which version of the JAX-WS RI I'm using?Run the following command
$ wsgen or wsimport -version
Alternatively, each JAX-WS jar has version information in
its
META-INF/MANIFEST.MF, such as this:
Build-Id: 12/14/2005 12:49 PM(dkohlert)
Build-Version: JAX-WS RI 2.0-12/14/2005 12:49 PM(dkohlert)-ea3
Q. Which version of Java does JAX-WS 2.0 require?
Java SE 5.0 and later. JAX-WS 2.0 relies heavily on the new language features available in Java SE 5.0.
Q. How do I run JAX-WS 2.1 with Java SE 5 and Java SE 6 ?
Q. What are the new features in 2.1 release ?
Q. If the WSDL binding adds additional headers, how can I add them to request ?
See http://weblogs.java.net/blog/kohsuke/archive/2006/11/adding_soap_hea.html
Q. Does 2.1 support spring framework ?
Yes. See http://weblogs.java.net/blog/kohsuke/archive/2007/01/spring_support.html
Q. Do I have to specify all attributes for annotations (like @WebService, @WebServiceRef etc)?
No - the respective specifications specify a well defined default values for all attributes of annotations.
Q. Does Java EE 5 platform support JAX-WS?
Yes. Java EE 5 platform supports JAX-WS based services (in addition to JAX-RPC based services) and makes them portable through JSR109.
Q. Is the stand alone JAX-WS-based service developed and deployed on Servlet container is portable on all Java EE 5 based platforms ?No.
Q. How do I make my standalone JAX-WS service portable across JavaEE5 platforms ?
Refer to this tip - http://java.sun.com/developer/EJTechTips/2006/tt0429.html#1
Q. Why does JAX-WS fetch WSDL during service creation ? Aren't the annotations on the genarted portable artifacts enough for runtime to work correctly ?
Roberto's response in http://forums.java.net/jive/thread.jspa?forumID=46&threadID=1168&messageID=22175#22175 :
"WSDL bindings are extensible. Moreover, with WS-Policy starting to be deployed, it's going to be even more complex to capture all the details in annotations, except in simple cases. We could have designed a mix of annotations and XML-based descriptors to capture all the information, but that's error -prone and quite static anyway. Either approach would have lead us to playing catch-up with the latest WSDL extensions with no end in sight.
So we decided to take a different route and use WSDL itself as the binding description language: after all, all the required information is there by definition. The drawback is that it requires accessing the WSDL at runtime. On the plus side, if more dynamic policies start being deployed (think of what WS-MetadataExchange permits), we won't need to make changes to the basic architecture.
I should add that we are looking at using a catalog mechamism like the Apache XML Commons Resolver to make it easy to package the required WSDL documents with the application and avoid expensive remote accesses at runtime."
Q. How can I change the Web Service address dynamically for a request ?
((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "...");
Q. How do I do basic authentication in JAX-WS ?
You can do the following:
HelloService service = new HelloService();
Hello proxy = (service.getHelloPort());
((BindingProvider)proxy).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "userfoo");
((BindingProvider)proxy).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "passbar");
USERNAME_PROPERTY, PASSWORD_PROPERTY are used primarily for service requests. I think when you instantiate Service, it fetches WSDL and the server is returning 401. You could try any one of the following solutions.
- 1. Use java.net.Authenticator class in your client application.
- 2. Provide a local access to the WSDL using catalog. There is a catalog sample in the jax-ws distribution.
- 3. Configure web.xml to allow GET requests without authentication
