Netbeans
Netbeans 5.5.1 comes with integrated Metro core (a.k.a JAX-WS RI) and a downloadable WSIT plugin. This allows you to develop web services solutions using easy to use GUI. NB 6 has integrated WSIT plugin.More on Metro and Netbeans see:
Basic Web Services
Adding Quality of Service(WS-* and .NET 3.0 interop)
Eclipse
The instructions below are for Eclipse for JavaEESetup
This is onetime setup- After starting Eclipse, select the J2EE perspective: Windows>Open Perspective>Others>J2EE
- In the lower window you should see a tab with label
Servers. Select the tab and right click in the window and select new>Server. - To download the GlassFish server, select Download additional server adapters. Accept the license and wait for Eclipse to restart.
- After Eclipse has restarted, you can create a new GlassFish V2 Java EE5 server.
- In the creation dialog select Installed Runtimes and select the directory where your GlassFish installation resides.
How to create a Web service
- To create the HelloWorld service, create a new dynamic Web project. Give it a name (e.g. helloworld) and select as target runtime GlassFish
- In that project you can create the class HelloWorld
package sample;
import javax.jws.WebService;
@WebService
public class HelloWorld {
public String hello(String param){
return param + ", World";
}
} - Deploy the service by selecting the project and select Run as>Run on server.
- Check that in the server Window that helloworld project has status Synchronized. If this is not the case, right-click in the server window and select publish.
- You can check that the GlassFish server is started and contains the Web service, by going to the admin console of GlassFish (localhost:4848)
See Arun's screen cast for the above steps.
Creating Web Service Client using Wsimport CLI
- Create a new project for the HelloWorld client (an ordinary Java project suffices).
- Select Add Glassfish v2 as Server Runtime in Build Path.
- Right clieck->BuildPath->Add Library->ServerRuntime->Glassfish v2
- Open a command window and go into the source directory of that project in Eclipse. For example, if the Eclipse workspace is in path
c:\home\vivekp\workspaceand the name of the project is echostringclient, then you need to go toc:\home\vivekp\workspace\helloworld\src. In this directory executewsimport -keep http://localhost:8080/helloworld/HelloWorldService?wsdl. On Linux or with Cygwin on Windows, you need to escape the ? by using \? instead. - Select refresh in the project view to see the generated files.
- Now you can create the client class HelloWorldClient
- You can execute the client, by selecting the HelloWorldClient in the package explorer of Eclipse and selecting Run>Java Application. In the console window of Eclipse, you should see "Hello World".
Creating Web Service Client using Wsimport Ant Task
You can pretty much avoid steps 3 - 5 above by using an Ant build.xml file.- Select helloworldclient in Package Exp and create a new file build.xml
- In this file (build.xml) copy the sample ant build script
- Then select build.xml in the package explorer, then Right Click->Run As->Ant Build...
- Invoke client target, it will run wsimport ant task and generate the client side stubs
- Invoke run to invoke the endpoint and run the client or you can execute the client, by selecting the HelloWorldClient in the package explorer of Eclipse and selecting Run>Java Application. In the console window of Eclipse, you should see "Hello World".
Creating Web Service Client using SOAP UI Plugin
- Inside Eclipse, install SOAP UI Plugin
- Select "Help"/"Software Updates"/"Find and Install..."
- Select the "Search for new features to install" option
- Press the "New Remote Site" button and add http://www.soapui.org/eclipse/update/site.xml as the plugin URL
- Select Finish and the follow the dialogs to install the soapUI feature
- Create a new project for the HelloWorld client (an ordinary Java project suffices).
- Select Add Glassfish v2 as Server Runtime in Build Path.
- Right clieck->BuildPath->Add Library->ServerRuntime->Glassfish v2
- Select the project and Right Click->Soap UI->Add SOAPUI Nature, SOAP UI WebService item will be added in Project Explorer
- Select SOAP UI perspective
- Right click on Projects->hellowworlclient->Add WSDL from URL, enter the deployed service URL:
http://localhost:8080/helloworld/HelloWorldService?wsdl. This will import the wsdl and you will see HelloWorldPortBinding - Select HelloWorldPortBinding and Right Click->GenerateCode->JAX-WS Artifacts
- Enter the appropriate info in the JAX-WS Artifacts window
- Click Tools and enter the location of JAX-WS Wsimport, for example c:\glassfish\bin
- Click OK
- Then click Generate on JAX-WS Artifacts window, it will display dialog box the operation was successful. Switch back to Java Perspective, then refresh the src folder and you can see the wsimport generated classes
- Now implement your client code
package sample;
public class HelloWorldClient {
/**
* @param args
*/
public static void main(String[] args) {
//Create Service
HelloWorldService service = new HelloWorldService();
//create proxy
HelloWorld proxy = service.getHelloWorldPort();
//invoke
System.out.println(proxy.hello("hello"));
}
}
- You can execute the client, by selecting the HelloWorldClient in the package explorer of Eclipse and selecting Run>Java Application. In the console window of Eclipse, you should see "Hello World".
Netbeans offers an easy to use a comprehensive Metro tooling choice. On Eclipse you can use SOAP UI or ant build script or CLI or even Mavem based tools, which does not look bad. There is RFE on Eclipse and looks like it is being looked at.
For the Quality Of Service features (WS-* features) it is little difficult as manually creating/modifying WSIT configuration is hard, so we need equivalent of WSIT Plugin in NetBeans for Eclipse. It will be great if anyone would like to do the WSIT plugin for Eclipse. Please let us know if you are willing to write a WSIT plugin for Eclipse.
No comments:
Post a Comment