Creating Web Services Applications with IntelliJ IDEA



Similar documents
Creating Java EE Applications and Servlets with IntelliJ IDEA

Building and Using Web Services With JDeveloper 11g

T320 E-business technologies: foundations and practice

NetBeans IDE Field Guide

JBoss SOAP Web Services User Guide. Version: M5

IBM Operational Decision Manager Version 8 Release 5. Getting Started with Business Rules

Workshop for WebLogic introduces new tools in support of Java EE 5.0 standards. The support for Java EE5 includes the following technologies:

This tutorial provides detailed instructions to help you download and configure Internet Explorer 6.0 for use with Web Commerce application.

SonicWALL CDP 5.0 Microsoft Exchange InfoStore Backup and Restore

WA2087 Programming Java SOAP and REST Web Services - WebSphere 8.0 / RAD 8.0. Student Labs. Web Age Solutions Inc.

Windows Firewall Configuration with Group Policy for SyAM System Client Installation

SARANGSoft WinBackup Business v2.5 Client Installation Guide

Learn how to create web enabled (browser) forms in InfoPath 2013 and publish them in SharePoint InfoPath 2013 Web Enabled (Browser) forms

Tool Tip. SyAM Management Utilities and Non-Admin Domain Users

Before you can use the Duke Ambient environment to start working on your projects or

1. Tutorial Overview

Novell ZENworks Asset Management 7.5

NSi Mobile Installation Guide. Version 6.2

TIBCO ActiveMatrix Service Bus Getting Started. Software Release 2.3 February 2010

How to set up Outlook Anywhere on your home system

Accessing Data with ADOBE FLEX 4.6

Tutorial for Avaya 4600 and 9600 Series IP Telephones Push and Browser Applications Setup

Richmond SupportDesk Web Reports Module For Richmond SupportDesk v6.72. User Guide

Developing Rich Web Applications with Oracle ADF and Oracle WebCenter Portal

Installing Client GPO Software

EVALUATION ONLY. WA2088 WebSphere Application Server 8.5 Administration on Windows. Student Labs. Web Age Solutions Inc.

Author: Gennaro Frazzingaro Universidad Rey Juan Carlos campus de Mostòles (Madrid) GIA Grupo de Inteligencia Artificial

Census. di Monitoring Installation User s Guide

Using the Query Analyzer

Business Process Management IBM Business Process Manager V7.5

Oracle Service Bus Examples and Tutorials

Java with Eclipse: Setup & Getting Started

Colligo Contributor File Manager 4.6. User Guide

Using Application Insights to Monitor your Applications

Web Service Development Using CXF. - Praveen Kumar Jayaram

Application. 1.1 About This Tutorial Tutorial Requirements Provided Files

Comodo ONE Software Version 1.8

Configuration Task 3: (Optional) As part of configuration, you can deploy rules. For more information, see "Deploy Inbox Rules" below.

CREATE A CUSTOM THEME WEBSPHERE PORTAL

Installing the Android SDK

etoken Enterprise For: SSL SSL with etoken

USING STUFFIT DELUXE THE STUFFIT START PAGE CREATING ARCHIVES (COMPRESSED FILES)

T320 E-business technologies: foundations and practice

Setting up VMware ESXi for 2X VirtualDesktopServer Manual

ECA IIS Instructions. January 2005

MadCap Software. Upgrading Guide. Pulse

ARCONICS CONTENT MANAGEMENT SYSTEM FOR UL


SysAid Remote Discovery Tool

Site Maintenance Using Dreamweaver

Reference and Troubleshooting: FTP, IIS, and Firewall Information

Glassfish, JAVA EE, Servlets, JSP, EJB

Designing portal site structure and page layout using IBM Rational Application Developer V7 Part of a series on portal and portlet development

Hypercosm. Studio.

Wavecrest Certificate

RoomWizard Synchronization Software Manual Installation Instructions

Tutorial 5: Developing Java applications

Configuration Guide. Remote Backups How-To Guide. Overview

Publishing, Consuming, Deploying and Testing Web Services

Tutorial - How to Use Lotus Domino Web Services in Java Development

PORTAL ADMINISTRATION

T320 E-business technologies: foundations and practice

Working with WebSphere 4.0

Instructions for Configuring a SAS Metadata Server for Use with JMP Clinical

Dreamweaver and Fireworks MX Integration Brian Hogan

Getting Started using the SQuirreL SQL Client

ELM Server Exchange Edition Virtual Archive Mailbox version 5.5

MIS Export via the FEM transfer software

Ricardo Perdigao, Solutions Architect Edsel Garcia, Principal Software Engineer Jean Munro, Senior Systems Engineer Dan Mitchell, Principal Systems

How To Use Query Console

How To Enable A Websphere To Communicate With Ssl On An Ipad From Aaya One X Portal On A Pc Or Macbook Or Ipad (For Acedo) On A Network With A Password Protected (

FTP, IIS, and Firewall Reference and Troubleshooting

The cloud server setup program installs the cloud server application, Apache Tomcat, Java Runtime Environment, and PostgreSQL.

How To Test Your Web Site On Wapt On A Pc Or Mac Or Mac (Or Mac) On A Mac Or Ipad Or Ipa (Or Ipa) On Pc Or Ipam (Or Pc Or Pc) On An Ip

Microsoft Expression Web

Creating a Java application using Perfect Developer and the Java Develo...

QuadraMed Enterprise Scheduling Combined Service Installation Guide. Version 11.0

Composite C1 Load Balancing - Setup Guide

Set up SSL in Deployment Solution 7.5

SuperOffice AS. CRM Online. Installing the Citrix Online Web plug-in

How to test and debug an ASP.NET application

How to add your Weebly website to a TotalCloud hosted Server

Chapter 2 Editor s Note:

AXIS 70U - Using Scan-to-File

In order to upload a VM you need to have a VM image in one of the following formats:

Composite.Community.Newsletter - User Guide

Pcounter Web Administrator User Guide - v Pcounter Web Administrator User Guide Version 1.0

Module 13 Implementing Java EE Web Services with JAX-WS

Advantage Joe. Deployment Guide for WebLogic v8.1 Application Server

Infor Xtreme Browser References

Content Management System Help. basic tutorial on Evergreen s CMS

DEVELOPING CONTRACT - DRIVEN WEB SERVICES USING JDEVELOPER. The purpose of this tutorial is to develop a java web service using a top-down approach.

Installing Hortonworks Sandbox on Hyper-V

Getting Started with the Standalone

How to install and use the File Sharing Outlook Plugin

Internet Explorer Browser Clean-up

GE Intelligent Platforms. Activating Licenses Online Using a Local License Server

Setting Up SSL on IIS6 for MEGA Advisor

Interact for Microsoft Office

Basic Setup Guide. Remote Administrator 4 NOD32 Antivirus 4 Business Edition Smart Security 4 Business Edition

Transcription:

Creating Web Services Applications with IntelliJ IDEA In this tutorial you will: 1. 2. 3. 4. Create IntelliJ IDEA projects for both client and server-side Web Service parts Learn how to tie them together Use various frameworks and technologies: Apache Axis, JAX-WS, RESTful Web Services Experience advanced IntelliJ IDEA coding assistance and code generation features Prerequisites To develop Web Services applications with IntelliJ IDEA, download the following software: 1. IntelliJ IDEA 8.1 or later release build. You can get it from http://www.jetbrains.com/idea 2. A compatible application server, for example, Apache Tomcat, available at http://tomcat.apache.org/ You may also want to check http://www.jetbrains.com/idea/training/demos.html and http://www. jetbrains.com/idea/documentation/documentation.html to get better insight into IntelliJ IDEA and its features. Creating Web Service: Apache Axis Prior to proceeding with the tutorial steps, make sure that an application server is installed on your machine. After that, launch IntelliJ IDEA and begin with creating a project from scratch. 1. Run IntelliJ IDEA. 1

2. On the File menu, click New Project. The New Project wizard appears. Click Next. 3. Specify the project name, for example, sampleserver. 2

4. Leave the option to create source directory selected and click Next. From the list of technologies, select 5. Web Application, then WebServices, and select Apache Axis from the list. Click Finish. 3

Now, IntelliJ IDEA generates the project with some sample code HelloWorld class. This is how the project structure should look. Sample HelloWorld class contains the generated code that concatenates a given string with Hello, world, from and then sends it back to the client along with printing to the server console. We only need to mark this class as one implementing a Web service by adding the @WebService annotation. IntelliJ IDEA suggests a quick-fix for it. Click the light bulb, or press Alt + Enter to automatically add annotation and corresponding import. Another quick-fix we need to apply is adding @WebMethod annotation. We ll need the sayhelloworldfrom method annotated, as we re going to expose it as a web service operation. When done, press Ctrl+Shift+F9 to compile the HelloWorld class. 4

We ve only few things left to do: expose the class as Web Service and generate the appropriate WSDL descriptor file. 1. Select the class name in the editor 2. Select Tools Web Services Expose Class as Web Service menu. 3. Click OK. IntelliJ IDEA automatically adds service description to the server-config.wsdd file: <service name= HelloWorld provider= java:rpc style= document use= literal > <parameter name= classname value= example.helloworld /> <parameter name= allowedmethods value= * /> <parameter name= scope value= Application /> <namespace>http://example</namespace> </service> 5

IntelliJ IDEA is also capable of generating WSDL descriptors directly from the Java code. 1. Select the class name in the editor 2. Select Tools Web Services Generate Wsdl From Java Code menu 3. All we need to do is click OK. The descriptor is generated automatically. Note. Web Service URL field shows you the URL at which this Web Service will be available. You will need this URL to generate client code later in this tutorial; the value can be found in the generated WSDL file: You can find all generated files in the project tree and edit them manually, if required. IntelliJ IDEA provides full coding assistance, including WSDL/WADL-aware code completion, plus inspections and quick-fixes, and even refactoring. 6

Let s deploy the Web Service to make sure everything works as expected. For that, we need to create an application server Run/Debug Configuration. 1. On the main menu, select Run and then click Edit Configurations. 2. Click plus button to add a configuration. As we already mentioned, we re using Tomcat server. 3. Specify the configuration name, for example, TomcatConfiguration. 7

In Server tab, click 4. Configure. Application Servers dialog appears. Click plus button to add the server configuration. In the Tomcat home field specify the folder where you have installed the server. 8

5. Click OK. Back in the Run/Debug Configuration dialog box, and then select the configured server from the Application Server list. Make sure the Start browser option is clear we don t need a Web browser launched for now. 6. Click Deployment tab. Select the web facet corresponding to sampleserver (notice that the facet has been automatically configured), and select the Deploy Web Facet Web option 7. Click OK to save the configuration. Now everything is ready to run, so just make sure the configuration is selected in the toolbar and press SHIFT+F10. IntelliJ IDEA compiles, deploys and runs the application. Our Web Service is now running and we re ready to move forward. 9

Creating Web Service Client: Apache Axis We need to create another project, sampleclient. It s essentially the same procedure as we ve used in the beginning of this tutorial. The only difference is that we have another selection of supported technologies. Namely, select the Web Services Client option and then select Apache Axis from the list. When you click Finish, IntelliJ IDEA asks you whether you want to open new project in a new frame or current one. Click New Frame. After the project is created, the following dialog pops up. 10

All we need to do here is specify the Web Service URL and click OK. Note: In general case, this URL depends on the container you use to deploy your web service, and can be retrieved from the deployment descriptor. In our case the url is http://localhost:8080/services/helloworld?wsdl. IntelliJ IDEA automatically generates the required code and project structure. Code editor opens with HelloWorldClient class from example package, which contains Live Template, with several fields where you need to specify a value by selecting one of choices offered by IntelliJ IDEA. After that, add a declaration for variable that will contain service response, plus the println call to display it in the console. 11

To run the client application, create a standard Java Application run configuration. The only option we need to configure is to specify example.helloworldclient as main class. Save configuration and press SHIFT+F10 to run it. Application will print the output to console. In the meantime, we can examine the server console to see that the same string has been printed there. Well done, we have just created a small example of Web Service and its client application with Apache Axis framework. Let s now have a look at a slightly different approach: JaxWS. 12

Creating Web Service: JaxWS Creating JaxWS Web Services has much in common with the already described Apache Axis procedure, so we ll go into details only if there is a difference from the previous procedure. 1. Run IntelliJ IDEA and choose File New Project. 2. Specify the project name and location. 3. From the list of technologies, select Web Application, then WebServices, and select Glassfish/JAX-WS 2.X RI/Metro 1.X/JWSDP 2.0. Click Finish. After IntelliJ IDEA creates the project, the sample code looks slightly different, because JaxWS relies on annotations instead of XML descriptors. 13

To generate WSDL descriptor right-click the class name in the editor and select WebServices Generate Wsdl From Java Code. As you can see, we need only to specify the URL for the WebService and click OK. The descriptor is generated. 14

Two things are left to do to run our WebService. 1. Create Tomcat run\debug configuration like you did for the WebService with Apahce Axis, and do not forget to set the Deploy Web Facet Web option at the Deployment tab of the run\debug configuration. 2. Press SHIFT+F10 to run the WebService. 15

Creating Web Service Client: JaxWS Client part for JaxWS Web Service is also a little different from that of Axis. 1. When creating the project, select Glassfish/JAX-WS 2.X RI/Metro 1.X/JWSDP 2.0 2. Generate code dialog requires fewer settings basically you only need to type WSDL URL 16

3. After the code is generated, modify it so that the client is properly initialized and sends some data to service. 4. Now, press CTRL+SHIFT+F10 to run the client. The response is printed in both consoles. 17

Creating Web Service: RESTful Web Services We ve already created sample projects using Apache Axis and JAX-WS. Now, it s time to try RESTful Web Services. 1. Run IntelliJ IDEA and start creating new project. On the technologies page of the New Project Wizard select Web Application WebServices RESTful Web Services. The project structure is already familiar to you, but the HelloWorld class looks a bit different. 18

In contrast to previous examples, we can run our web service right at this step, i.e. we do not need Tomcat configuration, the service can be launched using light-weight HTTP server. Just right-click anywhere in the HelloWold class code and select Run HelloWorld.main() from editor popup menu, or press Ctrl+Shift+F10. IntelliJ IDEA creates temporary run\debug configuration that you can save, if you want, and runs the service. Note: IntelliJ IDEA provides convenient tool window for testing RESTful web services with GET, POST, DELETE, PUT, HEAD and OPTIONS requests. Start debugging your service (right-click anywhere in the HelloWold class code and select Debug HelloWorld.main() ), then select Tools WebServices RESTful Web Services Test RESTful Web Service from the main menu to open the REST Client tool window, where you can easily browse the results of GET, POST, DELETE, PUT, HEAD and OPTIONS requests. 19

Before we pass on to creating RESTful client, we need to get WADL descriptor, and here is another trick. We have two ways of generating WADL: 1. The first one is similar to generating WSDL. Right-click the class name in the editor and select WebServices RESTful Web Services Generate WADL From Java Code. Specify Base URI and click OK. 2. For the second one we ll need REST Client tool window. While the service is running, right-click anywhere in the HelloWorld class in the editor, and select WebServices RESTful Web Services Test RESTful Web Service to access the tool window. Select GET from the HTTP method drop-down. Leave the Deployment end-point field as is, in the Path to resource drop-down select /application. wadl, then click Submit request button ( ). IntelliJ IDEA generates WADL descriptor, and displays it in the Response tab. 20

You can also debug your RESTful web service with the help of REST Client, which is very handy, when you need to examine DELETE or PUT requests, for example. 21

Creating Web Service: RESTful Web Services Client The client part creation is also extremely similar to the ones created in this tutorial 1. Create new project. On the technologies page, select Web Services Client RESTful Web Services. Click Finish. 2. In the dialog that appears specify the url to the generated WADL, or path to the locally stored WADL. 3. Client code is generated automatically. That s all for now. Of course, this tutorial only covers the essential topics you will need to build a Web Service application with IntelliJ IDEA. There s a lot more of things to explore and features that can help you enhance your application: integration with Hibernate, Spring, support for EJB, JSP, AJAX, integration with many popular application servers, and a whole lot more. Check out http://www.jetbrains.com/idea for additional details. 22