0% found this document useful (0 votes)
183 views

01-Getting Started With JAX-WS Web Services - NetBeans IDE Tutorial

Uploaded by

wajdiisamm
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
183 views

01-Getting Started With JAX-WS Web Services - NetBeans IDE Tutorial

Uploaded by

wajdiisamm
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 14
Getting Started with JAX-WS Web Services Java APL or XML Web Services UAX-WS), JSR 224, 6 an important part ofthe Java EE 5 and EE 6 platforms. A follow-up to the release of Java API for XML-based RPC 1.i(AX-RPC), JAX-WS simplifies the task of develoaing web services using Java technology. It adcresses some of the issues In JAX-RPC 2.1 by providing support for multiple protocols such as SOAP 3.1, SOAP 1.2, XML, and by providing 8 fait for supporting additional protocols along with HTTP. JAX-WS uses JAXB 2.0 for data binging and supports customizations o control generated service endpoint interfaces. With its support for annotations, JAX-WS simplifies Wed Service development and reduces the size of runtime JAR fies. ‘This document demonstrates the basics of using the IDE to develop a JAK-WS web service, After you create the web service, you rte three diferent web service chants tat use the web service over @ network, which is called "consuming" a web service. The thre clients are a Java class ina Java SE application, a Servet, ané @ JSP page in a web application. A more advancee tutorial focusing on cents ls Davalos JAX-WS Web Service Clin + Designing the Web Service "REQUIRES NetBeans: Y + Deploviog and Testiog the Web Service » Samoles + Consuming the Web Service in © a servlet in a web application © a JSP page ina web application To follow this tutor! you need the following software and resources. Software or Resource Version Required Neteans 198 Java download bundle Java Development kt 004) version 6 Tomeat web server 6.%-7.0 Java EE-compliant web or application server GlassFish Server Open Source Editon Oracle WebLogic Server oth Tomcat anc the GlassHish server can be instlleg wth the Web and Jove EE distribution of Neteans [DE. Alternatively, ‘you can visit the the GlassFish server downloads paae or the Apache Tomcat dowaloads page Creating a Web Service ‘The goal of this exercise isto ereate a project appropriate to the deployment container that you decide to use, Once you have & project, you wil create @ web service Init Choosing a Container You can etre deploy your web service n @ web contalner or in an EJB container. This cepends on your choice of Innplementaion. Ifyou are creating a Java EF 6 application, use a web container in any ease, because you can pu EIBS in a web application. For example, i you plan to éepley to the Tomcat Web Server, which only has a web container, create a wed applicaton, not an E38 module. dire 1. Choose File > New Project (CI-Shift-N). Select Web Application from the Java Web category oF EIB Module from the Java EE category, You can create 3 JAK-WS web service in a Maven project, Choose File > New Project (Ctrl-Shit-N) and then Maven Web Applicaton or Maven EJB module from the Maven category. It you haven't used Maven with NetSeane 2. Name the project Calculavocnsapelication. Selecta location for the projec. Click Next. 3. Select your server and Java EE version and cllek Fnsh To use the Oracle WebLogic server, celstar the server wih the IDE. Als, I you ara using the WebLogic server, watch the screencast on Deploving a Web Apolicaton to Oracle WebLoal, Creating a Web Service from a Java Class 1. Right-click the caiculatornsappiieation nede and choose Now > Web Service. 2. Name the web service calculatorts and type org.ne.caloulator in Package. Leave Create Web Service from Scratch selectee 5. Ifyou are creating 2 Jave EE 6 project, select Implement Web Service as a Stateless Session Bean steps Name and Location Goose Fe Tipe Seb Svs Nana Cabatrs 2. Nome and Lovation Propet: [Eablet sappleaton location: [FoucePacages Palaz seneieuar (© Crash Serie hom Seatch Cros Web Zevice fron Esti Session Demy eee) CES Ae © ne eb soaks Soe be OL 4, Click Finish. The Projects window displays the structure ofthe new web service and the source code is shown in the edor area. Adding an Operation to the Web Service .éds two numbers received from a cle “The goal of tis exercige Isto add tothe web service an operation th ‘The Neteans IDE provides a dialog for adding an operation to @ web service. You can open ths dialog elther inthe web service visual designer or in the web service context menu, Warning: The visual designer isnot avalable in Maven projects, To add an operation to the web service: Bsther © Change to the Design view in the editor. (Baamema a] Bes sore [Bem] tor [Simon a S/o operations nis one, a ‘uatyorserice a © Ontinis Tansee OfBrary Sata (TOM Reale Mest age Dsvory © Secu Serves ean) © Find the web service's node inthe Projects window Right-click that node. A context menu opens ax = @ cdidemo 5-8) maven cabulatr serene OQ were (8G Web Services 25 eu 0560 oT Ee nbn Edt Web Sore strites eee bate [escusiorsena Propet 2. Click Add Operaton in etter the visual designer or the context menu, A dalog box appears where you can define the new operation. 5. In the upper part of the Add Operation dilog box, type addin Name and type int in the Return Type drop-down lst. in the loner part af the Ald Operation lalog box, clek Add and create & parameter of type in: named :. Then cick Ade again and create a parameter of type sat called 3 You now see the following Nome: fase atu Type [nt 1 (Taranetere | Exceptions | Tine faa [aa ok | [cancer 4, Click OK at te bottom of the Add Operation dialog box. ‘The visual designer now displays the folowing

You might also like