SE 370: Programming Web Services Week 4: SOAP & NetBeans Copyright © Steven W. Johnson February 1, 2013.

Slides:



Advertisements
Similar presentations
HTML Forms. collect information for passing to server- side processes built up from standard widgets –text-input, radio buttons, check boxes, option lists,
Advertisements

Web Services Using SOAP, WSDL, and UDDI
WEB SERVICES. FIRST AND FOREMOST - LINKS Tomcat AXIS2 -
31242/32549 Advanced Internet Programming Advanced Java Programming
Introduction to Computing Using Python CSC Winter 2013 Week 8: WWW and Search  World Wide Web  Python Modules for WWW  Web Crawling  Thursday:
SOAP & Security IEEE Computer Society Utah Chapter Hilarie Orman - Purple Streak Development Tolga Acar - Novell, Inc. October 24, 2002.
SOAP.
SOAP : Simple Object Access Protocol
SOAP Overview Simple Object Access Protocol CSCI Topics in Software Engineering Web Infrastructure, Services, and Applications
CIS 375—Web App Dev II SOAP.
XML in the real world (2) SOAP. What is SOAP? ► SOAP stands for Simple Object Access Protocol ► SOAP is a communication protocol ► SOAP is for communication.
SOAP SOAP is a protocol for accessing a Web Service. SOAP stands for Simple Object Access Protocol * SOAP is a communication protocol * SOAP is for communication.
Topics Acronyms in Action SOAP 6 November 2008 CIS 340.
Web Services Darshan R. Kapadia Gregor von Laszewski 1http://grid.rit.edu.
Web Services Nasrullah. Motivation about web service There are number of programms over the internet that need to communicate with other programms over.
SOAP Lee Jong-uk. Introduction What is SOAP? The features of SOAP The structure of SOAP SOAP exchange message model & message Examples of SOAP.
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
SOAP Quang Vinh Pham Simon De Baets Université Libre de Bruxelles1.
Presentation 7 part 2: SOAP & WSDL. Ingeniørhøjskolen i Århus Slide 2 Outline Building blocks in Web Services SOA SOAP WSDL (UDDI)
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
TP2653 Adv Web Programming SOAP and WSDL. SOAP Simple Object Access Protocol – Lightweight XML-based messaging protocol – A protocol for accessing a Web.
INTRODUCTION TO WEB DATABASE PROGRAMMING
1 Homework / Exam Exam 3 –Solutions Posted –Questions? HW8 due next class Final Exam –See posted schedule Websites on UNIX systems Course Evaluations.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
SSC2: Web Services. Web Services Web Services offer interoperability using the web Web Services provide information on the operations they can perform.
TCP/IP Protocol Suite 1 Chapter 22 Upon completion you will be able to: World Wide Web: HTTP Understand the components of a browser and a server Understand.
SOAP Tutorial Ching-Long Yeh 葉慶隆 Department of Computer Science and Engineering Tatung University
James Holladay, Mario Sweeney, Vu Tran. Web Services Presentation Web Services Theory James Holladay Tools – Visual Studio Vu Tran Tools – Net Beans Mario.
Web Server Administration Web Services XML SOAP. Overview What are web services and what do they do? What is XML? What is SOAP? How are they all connected?
Presentation: SOAP/WS in a distributed object framework, Application Servers & AXIS SOAP.
Website Development with PHP and MySQL Saving Data.
Presentation: SOAP/WS in a distributed object framework, Application Servers & AXIS SOAP.
1 Web Services Web and Database Management System.
2007cs Servers on the Web. The World-Wide Web 2007 cs CSS JS HTML Server Browser JS CSS HTML Transfer of resources using HTTP.
1 WWW. 2 World Wide Web Major application protocol used on the Internet Simple interface Two concepts –Point –Click.
Kemal Baykal Rasim Ismayilov
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
S O A P ‘the protocol formerly known as Simple Object Access Protocol’ Team Pluto Bonnie, Brandon, George, Hojun.
SOAP Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
EGEE is a project funded by the European Union under contract IST SOAP Simple Object Access Protocol 3 – 4 June
Netprog: Soap & XML-RPC1 XML-RPC and SOAP. Netprog: Soap & XML-RPC2 XML Extensible Markup Language Markup Language. –HTML is also a markup language (but.
Introduction to Web Services Presented by Sarath Chandra Dorbala.
Lecture VI: SOAP-based Web Service CS 4593 Cloud-Oriented Big Data and Software Engineering.
1 G52IWS: Web Services Description Language (WSDL) Chris Greenhalgh
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
Beginning 자바 웹 서비스 SOAP 강미란 Cyber-Infrastructure Research Lab Konkuk University.
SOAP, Web Service, WSDL Week 14 Web site:
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 9 Web Services: JAX-RPC,
National College of Science & Information Technology.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
WWW and HTTP King Fahd University of Petroleum & Minerals
Web Development Web Servers.
Web Programming Developing Web Applications including Servlets, and Web Services using NetBeans 6.5 with GlassFish.V3.
Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
PHP / MySQL Introduction
Tutorial (4): HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Web Server Administration
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
HTTP Request Method URL Protocol Version GET /index.html HTTP/1.1
Deepak Shenoy Agni Software

Presentation transcript:

SE 370: Programming Web Services Week 4: SOAP & NetBeans Copyright © Steven W. Johnson February 1, 2013

SOAP-based web services Nusoap SOAP web services in: PHP NetBeans (Java) This week: 2

Client has limited alternatives: data is a single value data is an array data has multiple values (SOAP) data is constants (written into the code) data is variables (collected from a form) Conceptual web services: 3

Server has limited number of alternatives: simple calculation/print text (‘Hello World’) complex calculation using many variables writes query using variables; database read/update operation to a table return single variable return an array Conceptual web services: 4

5 server serialize de-serialize client Data appears as: single value array function parameters Data collected by: constants in code dorm inputs document Data processed: simple single calculation complex calculation prepare data as a query Data used by: function query/database table Data transferred as: variable array

SOAP: 6 Last week, XML-RPC; this week, SOAP XML-RPC is the BASIC of web services SOAP is the C of web services Rules Structure Format

SOAP: 7 SOAP more verbose; more capable SOAP is about document transfer SOAP requires an IDE If you like polymorphic accessors, enumerations, and orthogonal protocol binding, then SOAP is for you

SOAP: 8 SOAP adds to XML-RPC: user-defined data types specify recipient message specific processing control others NOT (as) easy to use Biggest advantage: customization of message

SOAP: 9 SOAP: Simple Object Access Protocol Platform and language independent HTTP and XML, like XML-RPC Difference: files instead of data Supports different protocols and formats: HTTP, SMTP, MIME W3C recommendation (2003) ≈44 pages long (not so short)

Ways to use SOAP: HTTP FTP I/O Jabber SMTP POP3 TCP MQSeries SOAP: 10

Has three elements: may include fault element CANNOT contain a DTD reference CANNOT hold XML processing instructions SOAP: 11

SOAP: 12 SOAP skeleton:

SOAP: 13 SOAP header: Optional; first child of Envelope if present Holds application-specific information Defines how to process SOAP message three defined attributes to default namespace: mustUnderstand Actor encodingStyle

SOAP: 14 SOAP envelope: root element of SOAP message holds one body element SOAP body element: held in envelope IBM

Nusoap: 15 Used with PHP; a collection of PHP classes Allows rpc/encoded & document/literal services Has some similarites with XML-RPC Dietrich Ayala

‘nusoap’ is the library (collection of PHP classes) Converts PHP into XML (SOAP envelopes) SOAP 1.1, WSDL 1.1, and HTTP 1.0/1.1 Version (2007) Nusoap: 16

The process: Nusoap: 17

Again, three files are used: client, server, library All files placed in web folder Nusoap: 18 www client.php server.php nusoap.php (SOAP library)

Nusoap: 19 server Nusoap client Nusoap serialize de-serialize

Create ‘client.php’ in Dreamweaver : Prints ‘Hello Scott’ to web page Nusoap: 20 <?php require_once('nusoap.php'); $client = new nusoap_client(' $result = $client->call('hello', array('name' => 'Scott')); echo ' Result '; print_r($result); echo ' '; ?> Uses ‘hello’ function Sends data Absolute address

Create ‘server.php’ in Dreamweaver: Nusoap: 21 <?php require_once('nusoap.php'); $server = new soap_server; $server->register('hello'); function hello($name) { return 'Hello, '. $name; } $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA); ?> if

Lab: Nusoap 22 POST /server.php HTTP/1.0 Host: User-Agent: NuSOAP/0.7.3 (1.114) Content-Type: text/xml; charset=ISO SOAPAction: "" Content-Length: 500 <SOAP-ENV:Envelope SOAP-ENV:encodingStyle=" xmlns:SOAP-ENV=" xmlns:xsd=" xmlns:xsi=" xmlns:SOAP-ENC=" Scott Request: header/xml generated by ‘client’

Response: header/xml generated by ‘server’ Lab: Nusoap 23 HTTP/ OK Date: Fri, 15 Mar :38:22 GMT Server: Apache/ (Win32) mod_ssl/ OpenSSL/0.9.8o PHP/5.3.3 DAV/2 X-Powered-By: PHP/5.3.3 X-SOAP-Server: NuSOAP/0.7.3 (1.114) Content-Length: 518 Vary: User-Agent,Accept-Encoding Connection: close Content-Type: text/xml; charset=ISO <SOAP-ENV:Envelope SOAP-ENV:encodingStyle=" xmlns:SOAP-ENV=" xmlns:xsd=" xmlns:xsi=" xmlns:SOAP-ENC=" Hello, Scott

‘client’ calls ‘server’ for processing of data: Processing function can be much more complex Lab: Nusoap 24 <?php require_once('nusoap.php'); $client = new nusoap_client(' $result = $client->call('hello', array('name' => 'Scott')); echo ' Result '; print_r($result); echo ' '; ?> <?php require_once('nusoap.php'); $server = new soap_server; $server->register('hello'); function hello($name) { return 'Hello, '. $name; } $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA); ?> “Scott” $name = “Scott”

Copy/paste ‘nusoap’ into your web server Fix the URL, change name to your name Open page: localhost/nusoap/client.php Lab: Nusoap 25

Copy/paste ‘dice’ into your web server Holds: client server library 6 images of a die (zar) Lab: Dice 26

Working page: Lab: Dice 27

Code required (server): ignore the passed variable (eliminate??) return is an array, must define random number generator: (returns int) Lab: Dice 28 mt_rand(1,6);//more efficient rand(1,6); $client->call('hello'); $result = []; 3.png 125px x 125px

Code required (client): function arguments = parameters remove messages add form, images, text output Lab: Dice 29.png" width="125" height="125">

Done! Lab: Dice 30

Client code (PHP): Lab: Dice 31 <?php if(isset($_POST['button'])) { require_once('nusoap.php'); $client = new nusoap_client(' $err = $client->getError(); // Check for an error if ($err) { echo ' Constructor error '. $err. ' '; } $result = $client->call('hello'); } ?>

32 table { margin-left: auto; margin-right: auto; }.png" width="125" height="125">.png" width="125" height="125"> Your spin = <?php echo $result[0] + $result[1]; ?>

Server code (PHP): Lab: Dice 33 <?php // Pull in the NuSOAP code require_once('nusoap.php'); // Create the server instance $server = new soap_server; // Register the method to expose $server->register('hello'); // Define the method as a PHP function function hello() { $result = []; $result[0] = mt_rand(1, 6); $result[1] = mt_rand(1, 6); return $result; } // Use the request to (try to) invoke the service $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server->service($HTTP_RAW_POST_DATA); ?>

Break 34

SOAP best built in IDE Our IDE: NetBeans, IDE for Java programming* Default: UniServer isn’t Java enabled Time for new web stack NetBeans: 35 Programming Language Web Server DatabaseDatabase Language Engines Operating System

NetBeans: IDE for Java programming* Download: NetBeans 7.3 (64-bit) includes: GlassFish (application & web server) Apache Tomcat (Java servlets) NetBeans: 36

An open source IDE Primary aim: Java Supports: HTML/5, PHP, C/C++, etc. Started as a school project Purchased by Sun Purchased by Oracle What is NetBeans? 37

Java Programming environment: Java Server Pages (replaces PHP) Tomcat Glassfish server (Replaces Apache) NetBeans: 38

Java Server Pages Serves same function as.php and.asp Java is compiled NetBeans: 39

All three: are server side technologies allow scripting to be mixed HTML require server software (compiler/interpreter) ASP and JSP may require application server JSP is an extension on a web page; uses servlets PHP is a programming language; uses scripts NetBeans: 40

Biggest differences: strictly data typed requires an application server (compiler) instead of NetBeans: 41 Some even numbers: <% int loop = 1; for (int i=0; i Even number :. Done.

GlassFish: an application server also serves web pages open source manages JavaEE applications NetBeans: 42 *many IDEs offer support in many programming paradigms

What’s an application server? A server that hosts applications PHP: interprets and then sends appserver: runs code embedded in web pages connect to databases connect to middleware provides methods clients can call.asp and.jsp are big users NetBeans: 43 *many IDEs offer support in many programming paradigms

What’s an application server? NetBeans: 44 receives request sends response data/method calls sends output creates or locates html method of communication: http information passed: markup compiles executables/run processes method of communication: anything information passed: program logic Web Server Application Server

Tomcat: Servlet container Made by Apache Open source web server Components: Catalina: servlet container Coyote: HTTP connector Jasper: a JSP engine (compiler) NetBeans: 45 *many IDEs offer support in many programming paradigms

Compiles servlets on.jsp Effect: like PHP interpreter for Java NetBeans: 46 Web Server Servlet Container HTTP Request HTTP Response Client

NetBeans 7.4 (windows) includes JDK Start Extract: Installing NetBeans: 47

Start Install: Installing NetBeans: 48

Do lots of thinking and installing Place shortcut in Quick Launch Installing NetBeans: 49

Close start page Installing NetBeans: 50

Editor good for single-file solutions IDE good when solutions require several files Example: C code source code libraries object files linker files executable IDE versus editor: 51

Projects: Holds all files necessary for integrated solution “A folder” holding a multi-file solution A workspace holds many projects Projects hold many folders/files that complete a task IDE versus editors: 52

Create a new project: ‘test’ (.html) NetBeans: 53

NetBeans: 54

Create a new project: ‘test’ (.jsp) NetBeans: 55

NetBeans: 56

Right click on Project name and ‘run’ NetBeans: 57

Check your ‘Output’ panel NetBeans: 58

Start GlassFish manually (ONLY if needed): Services window Right-click server node Start NetBeans: 59

Unblock the port for Java SOAP web services & NetBeans: 60

Generates a blank web page (port :8080) NetBeans: 61

Two instances of Java running (after run) One instance of NetBeans SOAP web services & NetBeans: 62

Running netstat –ao to check ports: SOAP web services & NetBeans: 63

PID of ports goes to ‘big Java’ SOAP web services & NetBeans: 64

If GlassFish doesn’t start… Turkish locale seems to be an issue SOAP web services & NetBeans: 65

Netbeans_default_options Add to end: SOAP web services & NetBeans: 66 "-J-Duser.language=en -J-Duser.region=US"

Location of saved work: NetBeans: 67

Holds all files necessary for integrated solution “A folder” holding a multi-file solution A workspace holds many projects Projects hold many folders/files that complete a task Projects: 68

Open NetBeans: (wizard approach) File – New Project Categories: “Java Web” Projects: “Web Application” Next Hello NetBeans web service: 69

Project name: “HelloNetBeans” (folder name) Next 70 Hello NetBeans web service:

Accept default settings Finish 71 Hello NetBeans web service:

‘Client’ page is generated (index.jsp) 72 Hello NetBeans web service:

Right-click project, run (test the.jsp file) 73 Hello NetBeans web service:

Right click on project name New – Web Service (order probably different) 74 Hello NetBeans web service:

Web Service Name: ‘HelloWorld’ Package: ‘com.javapapers.webservice’ Finish 75 Hello NetBeans web service:

HelloNetBeans.java (service code) 76 /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package com.javapapers.webservice; import javax.jws.WebService; import javax.jws.WebMethod; import javax.jws.WebParam; /** * Steve = "Hello") public class Hello { /** * This is a sample web service operation = "hello") public String = "name") String txt) { return "Hello " + txt + " !"; } Hello NetBeans web service:

Next step, update the.wsdl View the current.wsdl: (works in IE, Chrome) Hello NetBeans web service:

78 Hello NetBeans web service:

Next step, set up ‘client’ (index.jsp) Remove text “Hello World” 79 Hello NetBeans web service:

Right click on project name Choose: New – ‘Web Service Client…’ 80 Hello NetBeans web service:

WSDL URL: Package: com.javapapers.webserviceclient Click ‘finish’; project rebuilt ‘localhost’ okay 81 Hello NetBeans web service:

Right click on.jsp page Select ‘Web Service Client Resources’ Select ‘Call Web Service Operation…’ 82 Hello NetBeans web service:

Select ‘Hello’ from this dialog box and ‘OK’ Expand out tree if necessary 83 Hello NetBeans web service:

Code brings in ‘Hello’ from server file 84 Hello NetBeans web service:

Update the text string: ‘Hello’ is text from XML ‘Steve’ is text from ‘index’ 85 Hello NetBeans web service:

Save your files Right click on project name, run code 86 Hello NetBeans web service:

Complete! 87 Hello NetBeans web service:

Files of interest: index.jsp (‘client’) HelloWorld.java (‘server’) HelloWorld.wsdl 88 Hello NetBeans web service:

index.jsp (client): NetBeansProjects/HelloNetBeans/web/index.jsp 89 <%-- Document : index Created on : Mar 11, 2014, 10:06:36 PM Author : Steve --%> JSP Page <% try { com.javapapers.webserviceclient.Hello_Service service = new com.javapapers.webserviceclient.Hello_Service(); com.javapapers.webserviceclient.Hello port = service.getHelloPort(); // TODO initialize WS operation arguments here java.lang.String name = "Steve"; // TODO process result here java.lang.String result = port.hello(name); out.println("Result = "+result); } catch (Exception ex) { // TODO handle custom exceptions here } %> Hello NetBeans web service:

Hello.java: NetBeansProjects/Wk4HelloWorld/src/java/com/javapapers/ webservice/Hello.java 90 /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.javapapers.webservice; import javax.jws.WebService; import javax.jws.WebMethod; import javax.jws.WebParam; /** * Steve = "Hello") public class Hello { /** * This is a sample web service operation = "hello") public String = "name") String txt) { return "Hello " + txt + " !"; } Hello NetBeans web service:

HelloWorld.wsdl: NetBeansProjects/Wk4HelloWorld/build/web/WEB-INF/ wsdl/localhost_8080/HelloNetBeans/Hello.wsdl 91 <xsd:import namespace=" schemaLocation=" Hello NetBeans web service:

HelloWorld.wsdl: NetBeansProjects/Wk4HelloWorld/build/web/WEB-INF/ wsdl/localhost_8080/Wk4HelloWorld/HelloWorld.wsdl 92 Hello NetBeans web service:

1. SOAP messages are defined using an: A.XML DTD B.XML Schema C.XSLT D.XML CSS Quiz: 93

2. XML-RPC compared to SOAP: A.Is easier and more powerful B.Is easier and less powerful C.Is more complex and more powerful D.Is more complex and less powerful Quiz: 94

3. An XML-RPC message compared to a SOAP message: A.The XML-RPC message is smaller and carries more data B.The XML-RPC message is larger and cards more data C.The SOAP message is larger and carries more data D.The SOAP message is larger and it carries less data Quiz: 95

4. Comparing XML-RPC to SOAP: A.XML-RPC allows for the message to be customized B.SOAP allows for the message to be customized C.XML-RPC is sent using HTTP only D.SOAP is sent using HTTP only Quiz: 96

5. XML-RPC and SOAP: A.XML-RPC can be made in Notepad B.SOAP can be made in Notepad C.Both must be made using an IDE Quiz: 97

6. Java Server Pages (JSP): A.Are a web services technology B.Are a client-side technology C.Are a server-side technology D.Allow scripting to be mixed with HTML E.Scripts are executed before the page is rendered F.Scripts are executed after the page is rendered Quiz: 98

7. An application server: A.Inserts the output from scripts into HTML content B.Inserts the output from compiled code into HTML content C.Executes compiled code on the client machine D.Executes scripted code on the client machine Quiz: 99

SE 370: Programming Web Services Week 4: SOAP & NetBeans Copyright © Steven W. Johnson February 1, 2013

101 Build a more complete service Build ‘client’: pass 2 integers to ‘server’ answer displayed on web page more customized approach (less “wizardy”) Lab: AddNumbers

102 Create the project: Lab: AddNumbers

103 Rt. click on project name – New – web service Creates the *.java page (Name = filename) Lab: AddNumbers

104 Lab: AddNumbers /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.steve.johnson.add; import javax.jws.WebService; import javax.jws.WebMethod; import javax.jws.WebParam; /** * Steve = "AddingMachine") public class AddingMachine { /** * This is a sample web service operation = "hello") public String = "name") String txt) { return "Hello " + txt + " !"; }

105 Run the.jsp file Lab: AddNumbers

106 Now, new begins. Click on ‘Design’ Lab: AddNumbers

107 Modify ‘server’ = "hello") public String = "name") String txt) { return "Hello " + txt + " !"; } Lab: AddNumbers

108 Click ‘Add Operation…’ Lab: AddNumbers

109 Name = method name and method return type Arguments used by the method and data types Lab: AddNumbers

110 Method is = "Adder") public int = "one") int = "two") int two) { //TODO write your implementation code here: return 0; = "Adder") public int = "one") int = "two") int two) { //TODO write your implementation code here: return one + two; } Lab: AddNumbers

111 Select ‘hello’ and ‘Remove Operation’ Lab: AddNumbers

112 Right click on project and deploy Lab: AddNumbers

113 Test web Service Lab: AddNumbers

114 Lab: AddNumbers

115 Rt click on project - New – Web Service Client… Lab: AddNumbers

116 Click on Browse button for Project Browse in wsdl Lab: AddNumbers

117 Add a different package name at bottom Finish Lab: AddNumbers

118 Go to index.jsp file Right click in Source Window, Web Service Client – Web Service Operation Lab: AddNumbers

119 Drill down method on.java page OK Lab: AddNumbers

120 Change the ‘int’ variables to values Lab: AddNumbers

121 Delete ‘Hello World’ Save page Right-click in window and Run File Lab: AddNumbers

122 Output generated: Lab: AddNumbers

123 Use text fields to get data One text field, one int field Lab: Adult

124 Create the project: Lab: Adult

125 Open the Palette (Ctrl + Shift + 8) Window – IDE Tools – Palette Drag-and-drop support, no WYSIWYG yet Lab: Adult JSP Page

126 Change title to “Age Status” Delete element Lab: Adult JSP Page Hello World! Age Status

127 Need four elements? form table? 2 text fields 1 submit button Rules of HTML are the same in.jsp as.php Lab: Adult

128 Lab: Adult Create form Create table

129 Lab: Adult Add text fields:

130 Lab: Adult Name: Age: Add labels: (manually enter)

131 Lab: Adult Name: Age: Add submit button:

132 Lab: Adult Check work: save and run the page Names of elements shown on page Name Age Submit

133 Lab: Adult Build the web service Rt. Click on project name – New – Web Service

134 Lab: Adult /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.steve.johnson.adult; import javax.jws.WebService; import javax.jws.WebMethod; import javax.jws.WebParam; /** * Steve = "AdultMinor") public class AdultMinor { /** * This is a sample web service operation = "hello") public String = "name") String txt) { return "Hello " + txt + " !"; } AdultMinor.java

135 Update the web service method Lab: Adult

136 Click ‘Add Operation…’ Lab: Adult

137 Name = method name and method return type Arguments used by the method and data types Lab: Adult

138 Select ‘hello’ and ‘Remove Operation’ Lab: Adult

139 Right click on project and deploy Lab: Adult

140 Re-run index.java Lab: Adult

141 AdultMinor.java: Lab: Adult package com.steve.johnson.adult; import javax.jws.WebService; import javax.jws.WebMethod; import javax.jws.WebParam; /** * Steve = "AdultMinor") public class AdultMinor { /** * Web service operation = "AgeTest") public String = "Name") String = "Age") int Age) { //TODO write your implementation code here: return null; }

142 Fix the ‘AgeTest’ method: Lab: Adult /** * Web service operation = "AgeTest") public String = "Name") String = "Age") int Age) { if (Age < 18) {return Name + " is a minor";} else {return Name + " is an adult";} } }

143 Save.java file and test web service Lab: Adult

144 Save.java file and test web service Lab: Adult

145 Save.java file and test web service Lab: Adult

146 Rt click on project - New – Web Service Client… Lab: Adult

147 Click on Browse button for Project browse in wsdl add a different package name Lab: Adult

148 Go to index.jsp file Right click in Source Window, Web Service Client – Web Service Operation Lab: Adult

149 Lab: Adult Connect the form to the web service

150 Lab: Adult Extract text field values

151 Lab: Adult No ‘isset’ for the submit button Save ‘index.jsp’ Run

Break 152

Create a web service that finds the average of five scores Print that average score to a text field Watch your data types Assignment: 153 Score 1: Score 2: Score 3: Score 4: Score 5: Average: Submit

SE 370: Programming Web Services Week 4: SOAP & NetBeans Copyright © Steven W. Johnson February 1, 2013