Web services with intellij idea

Solo disponible en BuenasTareas
  • Páginas : 9 (2033 palabras )
  • Descarga(s) : 0
  • Publicado : 19 de mayo de 2010
Leer documento completo
Vista previa del texto
Creating Web Services Applications with IntelliJ IDEA
In this tutorial you will: 1. Create IntelliJ IDEA projects for both client and server-side Web Service parts 2. Learn how to tie them together 3. Use various frameworks and technologies: Apache Axis, JAX-WS, RESTful Web Services 4. Experience advanced IntelliJ IDEA coding assistance and code generation features

To developWeb 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.

Creating Web Services Applications with 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.

Creating Web Services Applications with IntelliJ IDEA


4. Leave the option to create source directory selected and click Next.

5. From the list of technologies, select Web Application, then WebServices, and select Apache Axis from the list.Click Finish.

Creating Web Services Applications with IntelliJ IDEA


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 asa web service operation. When done, press Ctrl+Shift+F9 to compile the HelloWorld class.

Creating Web Services Applications with IntelliJ IDEA


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: http://example

Creating Web Services Applications with IntelliJ IDEA


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.

Creating Web Services Applications with IntelliJ IDEA


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...
tracking img