java webservices [closed]
We have a current Java EE project and a new requirement to introduce a webservice into the project. We develop on Rad 7 and deploy to Websphere 6.1, but this could change soon to deploy to tomcat.
What I was wondering is, what approach should we take for developing these webservices?
- Should we develop RESTful webservice开发者_StackOverflows and use JAXB?
- Should we use the web service generation tool in Rad 7 (this would tie us to websphere)
- Should we use the approach of generating our xml schema, generate wsdl file and then generate code from wsdl?
We are not interested in using Axis.
What would be the best approach, or what would people regard as the latest and greatest way of creating webservices in Java?
Going with JAX-WS/JAXB is a good idea. JAXB is part of the JDK now (in 1.6) so it's not going anywhere. JAX-WS is easily deployed with your web applications in Tomcat as well.
We've used Axis here in the past and we've had some difficulty with deploying those clients and services (we eventually got it worked out, but the documentation did not help nor did anything else we found on the internet).
Have you considered JAX-RS (JSR311) and/or its Sun reference implementation Jersey? Note that the R in JAX-RS stands for RESTful.
You can find more info/docs/blogs/tutorials about Jersey at sun.com here.
You might want to consider using Spring WS for SOAP services or using Spring MVC for RESTful. Here's a related blog entry to using Spring MVC with REST.
I was using JAX-WS/JAXB and I had a very good experience. As Andy said, it is in JDK, so everything is fine there.
Regarding your question for schema first or code first, as of my knowledge, it depends on your requirement. If you have restrictions for changing your web service interface (like the client is developed by some other team), go for the schema first approach (create WSDL and then use it).
If you are creating the web service and you have full control for the interface, as a Java developer, it will be easy for you to code and leave the WSDL generation with Java.
精彩评论