1 HRS2422 Web Services JAX-WS and SOAP. 2 0. Introduction  Web service – A software component stored on one computer that can be accessed via method.

Slides:



Advertisements
Similar presentations
Overview Environment for Internet database connectivity
Advertisements

Siebel Web Services Siebel Web Services March, From
WEB SERVICES. FIRST AND FOREMOST - LINKS Tomcat AXIS2 -
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.
Web Services Darshan R. Kapadia Gregor von Laszewski 1http://grid.rit.edu.
1 Introduction to XML. XML eXtensible implies that users define tag content Markup implies it is a coded document Language implies it is a metalanguage.
Presentation 7 part 2: SOAP & WSDL. Ingeniørhøjskolen i Århus Slide 2 Outline Building blocks in Web Services SOA SOAP WSDL (UDDI)
1 Chapter 12 Working With Access 2000 on the Internet.
 2006 Pearson Education, Inc. All rights reserved Web Services.
6/11/2015Page 1 Web Services-based Distributed System B. Ramamurthy.
A New Computing Paradigm. Overview of Web Services Over 66 percent of respondents to a 2001 InfoWorld magazine poll agreed that "Web services are likely.
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.
Servlets and a little bit of Web Services Russell Beale.
11 Web Services Dr. Miguel A. Labrador Department of Computer Science & Engineering
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
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.
COMPUTER TERMS PART 1. COOKIE A cookie is a small amount of data generated by a website and saved by your web browser. Its purpose is to remember information.
Computer Concepts 2014 Chapter 7 The Web and .
Christopher Paolini Computational Science Research Center College of Engineering San Diego State University Computational Science 670 Fall 2009 Monday.
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.
Web Services Dr. Awad Khalil Computer Science & Engineering Department AUC.
CSCI 6962: Server-side Design and Programming Web Services.
Web Services Description Language (WSDL) Jason Glenn CDA 5937 Process Coordination in Service and Computational Grids September 30, 2002.
Lecture 15 Introduction to Web Services Web Service Applications.
Web Services Week 7 Aims: A detailed look at the underlying mechanisms for communication between web services Objectives: SOAP, WSDL, UDDI.
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.
Web Services Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Distributed Programming CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Introduction to Server-Side Web Development Introduction to Server-Side Web Development using JSP and Web Services JSP and Web Services 18 th March 2005.
Copyright © 2013 Curt Hill SOAP Protocol for exchanging data and Enabling Web Services.
XML and Web Services (II/2546)
1 Web Servers (Chapter 21 – Pages( ) Outline 21.1 Introduction 21.2 HTTP Request Types 21.3 System Architecture.
Kemal Baykal Rasim Ismayilov
S O A P ‘the protocol formerly known as Simple Object Access Protocol’ Team Pluto Bonnie, Brandon, George, Hojun.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
Chapter 7: Creating and Consuming XML Web Services Understanding XML Web Services Creating XML Web Services Deploying and Discovering XML Web Services.
Understanding Web Applications Lesson 4. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understanding Web Page Development Understand Web.
ODS – Introduction to Web Services and BPEL Vakgroep Informatietechnologie Web Services & BPEL Design of Distributed Software.
IT533 Lectures ASP.NET AJAX.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
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.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 21 Java Servlets Wed. 11/22/00 based on material.
.NET Mobile Application Development XML Web Services.
Introduction to Web Services Presented by Sarath Chandra Dorbala.
1 G52IWS: Web Services Description Language (WSDL) Chris Greenhalgh
DEVELOPING WEB SERVICES WITH JAVA DESIGN WEB SERVICE ENDPOINT.
Net-centric Computing Web Services. Lecture Outline  What is Web Service  Web Service Architecture  Creating and using Java Web Services  Apache Axis.
The Java API for XML-Based Web Services. A Web Service example in Java SOAP-awareServlet (e.g. Apache Axis2) SOAP-awareServlet Any class processing the.
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.
12. DISTRIBUTED WEB-BASED SYSTEMS Nov SUSMITHA KOTA KRANTHI KOYA LIANG YI.
Java Web Services Orca Knowledge Center – Web Service key concepts.
28 Web Services.
Web Programming Developing Web Applications including Servlets, and Web Services using NetBeans 6.5 with GlassFish.V3.
Chapter 5 Remote Procedure Call
WEB SERVICES.
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.
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.
Chapter 9 Web Services: JAX-RPC, WSDL, XML Schema, and SOAP
Distributed System using Web Services
WEB SERVICES From Chapter 19, Distributed Systems
Chapter 42 Web Services.
Distributed System using Web Services
Presentation transcript:

1 HRS2422 Web Services JAX-WS and SOAP

2 0. Introduction  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

3  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

4 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

5  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 behalfproxy object  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

6 Interaction between a web service client and a web service.

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

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

Web Services Fundamentals

10 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

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

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

Defining the HugeInteger Web Service in 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.

14  Netbeans places 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 annotation can be called remotely  Methods that are not tagged are not accessible to clients that consume the web service

15 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 annotation – Optional element name indicates the parameter name that is exposed to the web service’s clients

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

17

18 Outline Declare that method add is a web method

19 Outline Declare that method subtract is a web method

20 Declare that method bigger is a web method

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

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 – Also builds the project if it has changed and starts the application server if it is not already running  To ensure a clean re-build of the entire project – Select Clean Project or Clean and Build Project

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

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

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

26 Testing HugeInteger ’s add method.

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

28 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

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

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

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

32 New Web Service Client dialog.

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

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

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

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

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

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

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

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

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

42 Outline UsingHugeInteger JFrame.java (7 of 10 )

43 Outline UsingHugeInteger JFrame.java (8 of 10 )

44 Outline UsingHugeInteger JFrame.java (9 of 10 )

45

46 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

47 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

48 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

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

50 6 Session Tracking in Web Services  It can be beneficial for a web service to maintain client state information – Eliminates the need to pass client information between the client and the web service multiple times – Enables a web service to distinguish between clients

Creating a Blackjack Web Service  To use session tracking in a Web service – Must include code for the resources that maintain the session state information – JAX-WS handles this for you via annotation – Enables tools like Netbeans to “inject” complex support code into your class – You focus on business logic rather than support code  Using annotations to add code is known as dependency injection  also perform dependency injection

Creating a Blackjack Web Service  WebServiceContext object – Enables a web service to access and maintain information for a specific request, such as session state annotation injects the code that creates a WebServiceContext object  MessageContext object – Obtained from WebServiceContext object – MessageContext object’s get method returns HttpSession object for the current client - Receives a constant indicating what to get from the MessageContext - MessageContext.SERVLET_REQUEST indicates that we’d like to get the HttpServletRequest object - Can then call HttpServletRequest method getSession to get the HttpSession object  HttpSession method getAttribute – Receives a String that identifies the Object to obtain from the session state

53 Outline Blackjack.java (1 of 4 ) Import classes used for session handling Inject code to create the WebServiceContext object

54 Outline Blackjack.java (2 of 4 ) Get an ArrayList of String s representing the current client’s deck from the session object Get the MessageContext and use it to obtain the HttpSession object for the current client

55 Outline Blackjack.java (3 of 4 ) Place the deck in the session object

56 Outline Blackjack.java (4 of 4 )

Consuming the Blackjack Web Service  In JAX-WS 2.0 – Client must indicate whether it wants to allow the web service to maintain session information – Cast the proxy object to interface type BindingProvider - Enables the client to manipulate the request information that will be sent to the server - Information is stored in an object that implements interface RequestContext - BindingProvider and RequestContext are created by the IDE when you add a web service client to the application – Invoke the BindingProvider ’s getRequestContext method to obtain the RequestContext object – Call the RequestContext ’s put method to set the property BindingProvider.SESSION_MAINTAIN_PROPERTY to true - Enables session tracking from the client side so that the web service knows which client is invoking the service’s web methods

58 Outline BlackjackGameJ Frame.java (1 of 18 ) Used to enable session tracking from the client application

59 Outline BlackjackGameJ Frame.java (2 of 18 ) Enable session tracking for the client

60 Outline BlackjackGameJ Frame.java (3 of 18 )

61 Outline BlackjackGameJ Frame.java (4 of 18 )

62 Outline BlackjackGameJ Frame.java (5 of 18 )

63 Outline BlackjackGameJ Frame.java (6 of 18 )

64 Outline BlackjackGameJ Frame.java (7 of 18 )

65 Outline BlackjackGameJ Frame.java (8 of 18 )

66 Outline BlackjackGameJ Frame.java (9 of 18 )

67 Outline BlackjackGameJ Frame.java (10 of 18 )

68 Outline BlackjackGameJ Frame.java (11 of 18 )

69 Outline BlackjackGameJ Frame.java (12 of 18 )

70 Outline BlackjackGameJ Frame.java (13 of 18 )

71 Outline BlackjackGameJ Frame.java (14 of 18 )

72 Outline BlackjackGameJ Frame.java (15 of 18 )

73 Outline BlackjackGameJ Frame.java (16 of 18 )

74 Outline BlackjackGameJ Frame.java (17 of 18 )

75 Outline BlackjackGameJ Frame.java (18 of 18 )