As a follow up from a previous blog, the Web Services plugin in IntelliJIDEA now supports GlassFish v2. Here are the steps I followed to deploy the Web service on GlassFish:
- I updated the plugin version from "0.6 build 2" to "0.7 build 1" as shown here.
- Using Project Settings (default shortcut Ctrl+Alt+S), configure GlassFish in the Web Services plugin as shown here.
- Following steps 1, 2, and 3 from the previous blog, I created a POJO and enabled Web service support as shown here. There is no need to add any GlassFish specific deployment descriptor. However make sure web.xml is using version 2.5 as shown here.
- Following Steps 4, 5, and 6 from the previous blog, I added the
@javax.jws.WebService
annotation and exposed the class as Web service as shown here. The menu item changed from "Expose Class as Web Service" to "Deploy Class as Web Service". I find this confusing since at this stage the service endpoint is not getting deployed. Instead, under the covers required artifacts are generated. There is an explicit deploy step later and it’s confusing to mix that here. I think it should be renamed back to "Expose Class as Web Service". - To configure and run the GlassFish instance and deploy the newly created module, follow the instructions as shown in Step 7 here.
- Once the GlassFish server has started, the endpoint is hosted at
http://localhost:8080/hello/services/Hello
.
Now, we need to invoke the Web service using the following steps:
- Add a new "Java Module" to the project by selecting "File", "New Module".
- Select the newly created module in the "Project" window. In "Tools" menu, select "WebServices", "Generate Java Code From Wsdl" as shown here. This generates the client-side artifacts and can be seen by expanding "src" node in "helloclient" module.
- Add a new class "HelloClient" in the "client" subnode of "src" as shown below:
public class HelloClient {
public static void main(String[] args) {
System.out.println(new HelloService().getHelloPort().sayHello("Duke"));
}
} - Build the module by selecting "helloclient" node, right-click, selecting "Make module "helloclient"".
- Add add
activation.jar
as a module library as shown here. - Right-click HelloClient, select "Run "HelloClient.main()"" (default shortcut Ctrl+Shift+F10).
- The output window shows the result as shown here.
Thanks to AdvancedTools for adding GlassFish v2 support to the Web Services plugin.
Technorati: NetBeans IntelliJ Eclipse GlassFish Web service WSIT
Related posts:- Web services in IntelliJIDEA using the Web Services plugin
- Creating and Invoking a Web service using GlassFish in NetBeans, IntelliJ, and Eclipse – Part 2
- Creating and Invoking a Web service using GlassFish in NetBeans, IntelliJ, and Eclipse – Part 3
- Creating and Invoking a Web service using GlassFish in NetBeans, IntelliJ, and Eclipse – Part 1
- Getting Started with GlassFish in IntelliJ IDEA
[Trackback] Interested in first-class support for GlassFish in IntelliJ IDEA ? Vote here. Since this is still a wish for IntelliJ developers, consider using NetBeans IDE that provide comprehensive support for GlassFish. Developing/deploying a Web service on GlassF…
Comment by Arun Gupta's Blog — May 1, 2007 @ 7:19 pm