Web Programming Developing Web Applications including Servlets, and Web Services using NetBeans 6.5 with GlassFish.V3.

Slides:



Advertisements
Similar presentations
Overview Environment for Internet database connectivity
Advertisements

Siebel Web Services Siebel Web Services March, From
31242/32549 Advanced Internet Programming Advanced Java Programming
Web Service Ahmed Gamal Ahmed Nile University Bioinformatics Group
Web Services Web Services are the basic fundamental building blocks of invoking features that can be accessed by an application program. The accessibility.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
Web Services Nasrullah. Motivation about web service There are number of programms over the internet that need to communicate with other programms over.
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
1 Chapter 12 Working With Access 2000 on the Internet.
6/11/2015Page 1 Web Services-based Distributed System B. Ramamurthy.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 42 Web Services.
 2007 Pearson Education, Inc. All rights reserved JAX-WS Web Services, Web 2.0 and Mash-Ups.
Week 2 IBS 685. Static Page Architecture The user requests the page by typing a URL in a browser The Browser requests the page from the Web Server The.
INTRODUCTION TO WEB SERVICES CS 795. What is a Web Service ? Web service is a means by which computers talk to each other over the web using HTTP and.
1 Web Services Visual C# 2008 Step by Step Chapter 30.
1 Java Server Programming zLecture 1 focuses on: yIntroduction to web services y Web Services using Axis y The bigger Picture: Introduction to J2EE y Java.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
1 Lecture 22 George Koutsogiannakis Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
A Scalable Application Architecture for composing News Portals on the Internet Serpil TOK, Zeki BAYRAM. Eastern MediterraneanUniversity Famagusta Famagusta.
1 HRS2422 Web Services JAX-WS and SOAP Introduction  Web service – A software component stored on one computer that can be accessed via method.
CSCI 6962: Server-side Design and Programming Web Services.
James Holladay, Mario Sweeney, Vu Tran. Web Services Presentation Web Services Theory James Holladay Tools – Visual Studio Vu Tran Tools – Net Beans Mario.
Lecture 15 Introduction to Web Services Web Service Applications.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
Application Layer Khondaker Abdullah-Al-Mamun Lecturer, CSE Instructor, CNAP AUST.
XML and Web Services (II/2546)
Kemal Baykal Rasim Ismayilov
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
Module: Software Engineering of Web Applications Chapter 2: Technologies 1.
Intro to Web Services Dr. John P. Abraham UTPA. What are Web Services? Applications execute across multiple computers on a network.  The machine on which.
Introduction to Web Services Presented by Sarath Chandra Dorbala.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
DEVELOPING WEB SERVICES WITH JAVA DESIGN WEB SERVICE ENDPOINT.
Jackson, Web Technologies: A Computer Science Perspective, © 2007 Prentice-Hall, Inc. All rights reserved Chapter 9 Web Services: JAX-RPC,
12. DISTRIBUTED WEB-BASED SYSTEMS Nov SUSMITHA KOTA KRANTHI KOYA LIANG YI.
Labs: Create, deploy and test a simple web service
Java Web Services Orca Knowledge Center – Web Service key concepts.
Jim Fawcett CSE681 – SW Modeling & Analysis Spring 2005
Servlets.
28 Web Services.
WEB SERVICES From Chapter 19 of Distributed Systems Concepts and Design,4th Edition, By G. Coulouris, J. Dollimore and T. Kindberg Published by Addison.
z/Ware 2.0 Technical Overview
Chapter 5 Remote Procedure Call
WEB SERVICES.
T Network Application Frameworks and XML Web Services and WSDL Sasu Tarkoma Based on slides by Pekka Nikander.
Writing simple Java Web Services using Eclipse
Web Services-JAX-RPC JAX-RPC enables a Web Service endpoint to be developed using either a Java Servlet or Enterprise JavaBeans (EJB) component model.
Unit – 5 JAVA Web Services
Web Services CO5027.
Processes The most important processes used in Web-based systems and their internal organization.
INTRODUCTION TO WEB SERVICES CS 795. What is a Web Service ? Web service is a means by which computers talk to each other over the web using HTTP and.
WEB API.
MSIS 655 Advanced Business Applications Programming
Chapter 27 WWW and HTTP.
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
Introduction to Servlets
Objectives In this lesson you will learn about: Need for servlets
JavaServer Faces: The Fundamentals
Serpil TOK, Zeki BAYRAM. Eastern MediterraneanUniversity Famagusta
COP 4610L: Applications in the Enterprise Spring 2005
Introduction to Web Services
Distributed System using Web Services
J2EE Lecture 1:Servlet and JSP
WEB SERVICES From Chapter 19, Distributed Systems
Chapter 42 Web Services.
Distributed System using Web Services
Java Chapter 7 (Estifanos Tilahun Mihret--Tech with Estif)
Presentation transcript:

Web Programming Developing Web Applications including Servlets, and Web Services using NetBeans 6.5 with GlassFish.V3

Web-Based –Client/Server Web Applications GlassFish / Server Browser / Client <html> contains Java </html> .JSP Local host port Web Form TCP Socket HTTP Headers Compiled to Get data object Servlet

I. Web Applications Java Server Pages Extension of servlet technology Each JSP is translated by the JSP container into a servlet Help separate presentation from content Help web application programmers create dynamic content By reusing predefined components By interacting with components using server-side scripting

1. Java Server Pages First request for a JSP Container translates the JSP into a servlet Servlet handles the current and future requests to the JSP JSPs rely on the same request/response mechanism as servlets to process requests from and send responses to clients

2. Servlets Use the HTTP request-response model of communication between client and server Extend a server’s functionality by allowing the server to generate dynamic content Servlet container executes and interacts with servlets Packages javax.servlet and javax.servlet.http contain the servlet classes and interfaces.

2. Servlets Servlet container Receives HTTP requests from clients Directs each request to the appropriate servlet Servlet processes the request and returns response to the client—typically an XHTML or XML document Servlets implement the Servlet interface of package javax.servlet Ensures that each servlet can execute in the framework Declares methods used by the servlet container to manage the servlet’s life cycle

3. Web-Based –Client/Server GlassFish / Server Browser / Client <html> contains Java </html> .JSP Local host port Web Form TCP Socket HTTP Headers Compiled to Get data object Servlet

Web-Based –Client/Server Web Services GlassFish / Server/JAVA EE SOAP/HTTP Simple Object Access Protocol Request Browser / Client J AVA/SOAP JSP Servlets HTML Java Client JDK 6.1 Java program(s) BEANS OBJECT Entity beans Session Beans Msg driven- beans Response

II. Web Services Web service A software component stored on one computer that can be accessed via method calls by an application (or other software component) on another computer over a network Web services communicate using such technologies as XML and HTTP Simple Object Access Protocol (SOAP) An XML-based protocol that allows web services and clients to communicate in a platform-independent manner

Companies Amazon, Google, eBay, PayPal and many others make their server-side applications available to partners via web services By using web services, companies can spend less time developing new applications and can create innovative new applications Netbeans 6.5 and Java EE enable programmers to “publish (deploy)” and/or “consume (client request)” web services

1. Java Web Services Basics Remote machine or server The computer on which a web service resides A client application that accesses a web service sends a method call over a network to the remote machine, which processes the call and returns a response over the network to the application In Java, a web service is implemented as a class that resides on a server Publishing (deploying) a web service Making a web service available to receive client requests Consuming a web service Using a web service from a client application

An application that consumes a web service (client) consists of two parts An object of a proxy class for interacting with the web service A client application that consumes the web service by invoking methods on the proxy object The proxy object handles the details of communicating with the web service on the client’s behalf JAX-WS 2.0 Requests to and responses from web services are typically transmitted via SOAP Any client capable of generating and processing SOAP messages can interact with a web service, regardless of the language in which the web service is written

Interaction between a web service client and a web service.

Traditional Web-Based Systems The overall organization of a traditional Web site.

“Multipurpose Internet Mail Extensions” Web Documents Six top-level MIME types and some common subtypes “Multipurpose Internet Mail Extensions”

Web Services Fundamentals

2. Creating, Publishing, Testing and Describing a Web Service Example: HugeInteger web service Provides methods that take two “huge integers” (represented as Strings) Can determine their sum, their difference, which is larger, which is smaller or whether the two numbers are equal

To create a web service in NetBeans 2.1 Creating a Web Application Project and Adding a Web Service Class in NetBeans In Netbeans, you focus on the logic of the web service and let the IDE handle the web service’s infrastructure To create a web service in NetBeans Create a project of type Web Application The IDE generates additional files that support the web application

2.2.2 Defining the HugeInteger Web Service in Netbeans Each new web service class created with the JAX-WS APIs is a POJO (plain old Java object) You do not need to extend a class or implement an interface to create a Web service When you compile a class that uses these JAX-WS 2.0 annotations, the compiler creates the compiled code framework that allows the web service to wait for and respond to client requests

2.2 Defining the HugeInteger Web Service in Netbeans @WebService annotation Indicates that a class represents a web service Optional element name specifies the name of the proxy class that will be generated for the client Optional element serviceName specifies the name of the class that the client uses to obtain a proxy object.

Netbeans places the @WebService annotation at the beginning of each new web service class you create You can add the optional name and serviceName elements in the annotation’s parentheses Methods that are tagged with the @WebMethod annotation can be called remotely Methods that are not tagged with @WebMethod are not accessible to clients that consume the web service

@WebMethod annotation Optional operationName element to specify the method name that is exposed to the web service’s client Parameters of web methods are annotated with the @WebParam annotation Optional element name indicates the parameter name that is exposed to the web service’s clients

Import the annotations used in this example Indicate that class HugeInteger is a web service

Outline Declare that method add is a web method

Outline Declare that method subtract is a web method

Declare that method bigger is a web method

Outline Declare that method smaller is a web method Declare that method equals is a web method

2.3 Publishing the HugeInteger Web Service from Netbeans Netbeans handles all the details of building and deploying a web service for you Includes creating the framework required to support the web service To build project Right click the project name in the Netbeans Projects tab Select Build Project To deploy Select Deploy Project Deploys to the server you selected during application setup Also builds the project if it has changed and starts the application server if it is not already running To Execute Select Run Project To ensure a clean re-build of the entire project Select Clean Project or Clean and Build Project

Pop-up menu that appears when you right click a project name in the Netbeans Projects tab.

Sun Java System Application Server 2.4 Testing the HugeInteger Web Service with Sun Java System Application Server’s Tester Web page Sun Java System Application Server Can dynamically create a Tester web page for testing a web service’s methods from a web browser Enable this feature via the project’s Run options To display the Tester web page Run the web application from Netbeans, or Type web service’s URL in browser’s address field followed by ?Tester Web server must be running for a client to access a web service If Netbeans launches the application server for you, the server will shut down when you close Netbeans To keep it running, launch it independently of Netbeans

Tester web page created by Sun Java System Application Server for the HugeInteger web service.

Testing HugeInteger’s add method.

To consume a web service 2.5 Describing a Web Service with the Web Service Description Language (WSDL) To consume a web service Must know where to find the web service Must be provided with the web service’s description Web Service Description Language (WSDL) Describe web services in a platform-independent manner The server generates a web service’s WSDL dynamically for you Client tools parse the WSDL to create the client-side proxy class that accesses the web service To view the WSDL for a web service Type URL in the browser’s address field followed by ?WSDL or Click the WSDL File link in the Sun Java System Application Server’s Tester web page

3. Consuming a Web Service Web service client can be any type of application or even another web service Web service reference Enables a client application to consume a web service Defines the client-side proxy class

A portion of the .wsdl file for the HugeInteger web service.

3.1 Creating a Client in Netbeans to Consume the HugeInteger Web Service When you add a web service reference IDE creates and compiles the client-side artifacts—the framework of Java code that supports the client-side proxy class Client calls methods on a proxy object Proxy uses client-side artifacts to interact with the web service To add a web service reference Right click the client project name in the Netbeans Projects tab Select New > Web Service Client… Specify the URL of the web service’s WSDL in the dialog’s WSDL URL field

3.1 Creating a Client in Netbeans to Consume the HugeInteger Web Service Netbeans uses the WSDL description to generate the client-side proxy class and artifacts Netbeans copies the web service’s WSDL into a file in your project Can view this file from the Netbeans Files tab Expand the nodes in the project’s xml-resources folder. To update client-side artifacts and client’s WSDL copy Right click the web service’s node in the Netbeans Projects tab Select Refresh Client To view the IDE-generated client-side artifacts Select the Netbeans Files tab Expand the project’s build folder

New Web Service Client dialog.

Netbeans Project tab after adding a web service reference to the project.

Locating the HugeIntegerService.wsdl file in the Netbeans Files tab.

Viewing the HugeInteger web service’s client-side artifacts generated by Netbeans.

Outline UsingHugeInteger JFrame.java (1 of 10 ) Declare variables used to obtain and access the proxy object Obtain the proxy object

Outline (2 of 10 ) Use the proxy to invoke web method add UsingHugeInteger JFrame.java (2 of 10 ) Use the proxy to invoke web method add

Outline (3 of 10 ) Use the proxy to invoke web method subtract UsingHugeInteger JFrame.java (3 of 10 ) Use the proxy to invoke web method subtract

Outline (4 of 10 ) Use the proxy to invoke web method bigger UsingHugeInteger JFrame.java (4 of 10 ) Use the proxy to invoke web method bigger

Outline (5 of 10 ) Use the proxy to invoke web method smaller UsingHugeInteger JFrame.java (5 of 10 ) Use the proxy to invoke web method smaller

Outline (6 of 10 ) Use the proxy to invoke web method equals UsingHugeInteger JFrame.java (6 of 10 ) Use the proxy to invoke web method equals

Outline UsingHugeInteger JFrame.java (7 of 10 )

Outline UsingHugeInteger JFrame.java (8 of 10 )

Outline UsingHugeInteger JFrame.java (9 of 10 )

5. SOAP SOAP (Simple Object Access Protocol) Commonly used, platform-independent, XML-based protocol that facilitates remote procedure calls, typically over HTTP Wire format or wire protocol Protocol that transmits request-and-response messages Defines how information is sent “along the wire” SOAP message (also known as a SOAP envelope) Each request and response is packaged in a SOAP message Contains information that a web service requires to process the message

5. SOAP SOAP message (also known as a SOAP envelope) Each request and response is packaged in a SOAP message Contains information that a web service requires to process the message Envelop Heder Header block Body

5 SOAP Wire format must support all types passed between the applications SOAP supports Primitive types and their wrapper types Date, Time and others Can also transmit arrays and objects of user-defined types Request SOAP message’s contents Method to invoke Method’s arguments Response SOAP message’s contents Result of method call Client-side proxy parses the response and returns the result to the client application SOAP messages are generated for you automatically

SOAP messages for the HugeInteger web service’s add method as shown by the Sun Java System Application Server’s Tester web page.