Apt vs wsgen vs wsimport. Conflict about what to use, when and why not to use another

I am trying to write a web service (JAX-WS), and I went through a series of tutorials starting from 2006 to 2013. Most of them relate to some IDE. Those who talk about manually creating / deploying a web service have ant scripts. So far, everything is fine.

At the moment of checking the ant scripts, confusion begins. some older tutorials use the APT task to compile the SEI, and then wsgen is used to generate artifacts. newer ones only use wsgen (although APT is defined as taskdef in ant scripts). Also, since I read about the JAVA 7 documentation, it says you don't need to use wsgen, since javac itself does all the req compilation and artifacts. for WS generated dynamically at runtime.

I tried using the javac command in SEI and deployed it to tomcat, but it did not work.

Can anyone explain what commands I need to use in the JAVA SE 7 version to deploy the web service.

In addition, I want to know what each command generates and when to use which commands.

According to my information, wsimport is not needed for development and deployment, but you only need to create a WS-client. It's right? If not, please provide me with pointers to clear my understanding.

Thanks at Advance

Also, if I repeat my self, I apologize because I'm new to StackOverflow and not very familiar with this. :)

+6
source share
1 answer

To create a web service using the Java-WS specification, you need a few artifacts. The purpose of "apt", "wsgen" and "wsimport" is to automate this procedure.

There are two ways to create a web service: Bottom-Up (First code, then WSDL) and Top-Down (first WSDL, then code).

An approach

bottom :

  • apt: uses source code, generates WSDL (and artifacts)
  • wsgen: uses compiled code, generates WSDL (and artifacts)

Top down

  • wsimport: uses WSDL, generates Java code to implement the service / client.

The advantage of using apt is that with the source code, the script will be able to get the parameter names and use them in the WSDL.

Web Services Deployment

For production, you will need a Web Container that can be responsible for security, scalability, and resource management, but for testing purposes, you can deploy your web services using the built-in web server in Java SE by doing:

@WebService public class MyService{ public static void main(String args[]){ MyService service = new MyService(); String url = "service/"; Endpoint ep = new Endpoint(url, service); } @WebMethod public String getInfo(){ return "Service info"; } } 

This piece of code will generate WSDL and publish the service to your localhost / service.

+9
source

All Articles