




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
webservices notes related to java
Typology: Lecture notes
1 / 177
This page cannot be seen from the preview
Don't miss anything!
Introduction to Web Services with
Java
Download free books at
Download free eBooks at bookboon.com 2
Introduction to Web Services with Java
Download free eBooks at bookboon.com Click on the ad to read more
Introduction to Web Services with Java
4
Contents
Contents
Preface 8
List of Figures 10
Table of Listings 12
Table of Tables 14
1 Introduction 15 1.1 Browsing the Internet 17 1.2 Web Service architecture 18 1.3 Benefits of Web Services 23 1.4 Program a HelloWorld Web Service 23 1.5 Host a Web Service 29 1.6 Verify a Web Service 29 1.7 Test a Web Service with SOAPUI 32
the of (^) th + - c (^) + in + + ity
- ste
Be a part of the equation. RMB Graduate Programme applications are now open. Visit www.rmb.co.za to submit your CV before the 23rd of August 2013.
Download free eBooks at bookboon.com Click on the ad to read more
Introduction to Web Services with Java
5
Contents
1.8 Create a Web Service Client 34 1.9 Run a Web Service Client 37 1.10 References 37
2 SOAP 38 2.1 Examples of SOAP messages 39 2.2 Mapping SOAP to HTTP 42 2.3 SAAJ Client 45 2.4 Summary 48 2.5 References 48
3 Web Service Description Language (WSDL) 50 3.1 WSDL structure 50 3.2 WSDL Interface 54 3.3 WSDL Implementation 55 3.4 References 56
4 A Sample Web Service Application 57 4.1 A Sample application 57 4.2 Develop a Web Service 73
Designed for high-achieving graduates across all disciplines, London Business School’s Masters in Management provides specific and tangible foundations for a successful career in business. This 12-month, full-time programme is a business qualification with impact. In 2010, our MiMemployment rate was 95% within 3 months of graduation*; the majority of graduates choosing to work in consulting or financial services. As well as a renowned qualification from a world-class business school, you also gain access to the School’s network of more than 34,000 global alumni – a community that offers support andopportunities throughout your career. For more information visit www.london.edu/mm , email mim@london.edu or give us a call on +44 (0)20 7000 7573.
Masters in Management
The next step for
top-performing
graduates
Download free eBooks at bookboon.com Click on the ad to read more
Introduction to Web Services with Java
7
Contents
7 Appendix A – Development Environment 169 7.1 Install Java Development Kit (JDK) 6 169 7.2 Install Eclipse Interactive Development Environment (IDE) 169 7.3 Install MySQL Community Server Database 173 7.4 Install Oracle Fusion Middleware Software 174 7.5 Install Apache Tomcat server 175 7.6 Apache CXF 175 7.7 Install SOAPUI software 176 7.8 Source Code 176
8 Endnotes 177
Download free eBooks at bookboon.com
Introduction to Web Services with Java
8
Preface
Preface
This book, which is based on lectures I provided at Trident University International, focuses more on the details of a hands-on approach to Web Service programming than its specifications; however, in order to help readers grasp the concept more easily, we provide a brief introduction to Web Service, SOAP, and WSDL in the first three chapters. Many details of the specifications are intentionally glossed over, however, so that the content remains manageable.
Objectives
Background requirements for this book:
Web Service (WS) is a technology, process, and software paradigm that provides support for business integrations mainly over an Internet-based environment. This book presents basic concepts of WS, protocol stack, and applications. In addition to studying the three supporting standards SOAP, WSDL, and UDDI, students will learn how to implement WS using Java-centric technologies such as JAXP, JAXRPC, SAAJ, and JAXB. Students will also study how business processes can be implemented using WS via BPEL.
WS is a software application identified by a URI whose interfaces and binding are capable of being defined, described, and discovered by XML artifacts, and it supports direct interactions with other software applications using XML-based messages via Internet-based protocols (W3C: http:// www.w3.org/TR/ ws-desc-reqs). WS is mainly for machine-to-machine communication. The WS standard relies on other standards – namely, SOAP, WSDL, and UDDI – to function efficiently. SOAP is an application protocol that is used to transmit messages between a WS client and a WS server. HTTP is the transport protocol of choice for SOAP; however, JMS and SMTP protocols have also been used. WSDL is used to describe the service that an external application can call. UDDI is used to publish and advertise services so that they can found and used by others. UDDI also uses SOAP as its application protocol.
Download free eBooks at bookboon.com
Introduction to Web Services with Java
10
List of Figures
List of Figures
Figure 1-1 Early Web applications Figure 1-2 Two-tier Web application Figure 1-3 An n-tier Web architecture Figure 1-4 Man-machine interaction Figure 1-5 Remote Procedure Call (RPC) Figure 1-6 Business-to-Business integration Figure 1-7 Sequence diagram of SOAP Figure 1-8 Web Service architecture Figure 1-9 An Eclipse Java project for the HelloWorld Web Service Figure 1-10 The WSDL of the HelloWorld Web Service Figure 1-11 The XML schema associated with the HelloWorld Web Service. Figure 1-12 Create a SOAPUI project for the HelloWorld Web Service Figure 1-13 Opening the HelloWorld WSDL Figure 1-14 Call an operation (method) of a Web Service Figure 2-1 SOAP message structure Figure 2-2 SOAP message exchange Figure 3-1 WSDL structure Figure 3-2 Linkages inside WSDL Figure 4-1 An n-tier application Figure 4-2 Use cases Figure 4-3 Sequence diagram of a getEmployee operation Figure 4-4 A simple deployment diagram Figure 4-5 Database schema (Chua Hock Chuan) Figure 4-6 Java project: data-svc Figure 4-7 Select import type Figure 4-8 Import archive file screen Figure 4-9 Java build path Figure 4-10 JAR selection screen Figure 4-11 Java build path Figure 4-12 java-ws Java project Figure 4-13 Create a SOAPUI project Figure 4-14 List of operations of a Web Service Figure 4-15 Execute SOAP operations Figure 4-16 Create a new SOAPUI project 3 Figure 4-17 Activities for creating a Web Service client Figure 4-18 Screenshot of java-ws-client Java project
Download free eBooks at bookboon.com
Introduction to Web Services with Java
11
List of Figures
Figure 5-1 Class diagram for a CXF Web Service Figure 5-2 Deployment diagram for a CXF Web Service Figure 5-3 Activities for creating a Web Service application Figure 5-4 Screenshot of a dynamic Web project Figure 5-5 Creating a new SOAPUI project Figure 5-6 Executing a Web Service operation Figure 5-7 Screenshot of cxf-ws-client Java project Figure 6-1 Deployment diagram for CXF Web Service application and Oracle WebLogic server Figure 6-2 Creating a WLS domain Figure 6-3 Adding extensions (JAX-WS and JAX-RPC) Figure 6-4 Enter the domain name Figure 6-5 Enter user ID and password Figure 6-6 Select a default JDK Figure 6-7 Adding a configuration Figure 6-8 Configuration summary of the domain Figure 6-9 Status of the domain creation Figure 6-10 Output of a WLS administration server Figure 6-11 OracleWLS console login screen Figure 6-12 Oracle WLS deployment screen Figure 6-13 Oracle WLS install application screen Figure 6-14 Type of deployment Figure 6-15 Additional settings for the deployment application process Figure 6-16 Deployment verification Figure 6-17 Select the Web Service application for testing Figure 6-18 Display of the Web application Figure 6-19 WebLogic test client Figure 6-20 Prepare to run getEmployee operation Figure 6-21 Result of a call to getEmployee operation Figure 7-1 Create a Java project for the Eclipse IDE Figure 7-2 Java settings screen Figure 7-3 Create a dynamic Web project Figure 7-4 Options for a dynamic Web project Figure 7-5 Additional Java options Figure 7-6 Finishing up the creation of a dynamic Web project Figure 7-7 Working Tomcat console screen
Download free eBooks at bookboon.com Click on the ad to read more
Introduction to Web Services with Java
13
Table of Listings
Listing 4-19 WSDL of a RPC Style Listing 4-20 XSD of a Web Service (RPC) Listing 4-21 An Additional XSD of a Web Service Listing 4-22 EmployeesDocClient.java Class Introduction to Web Services Listing 4-23 EmployeesRpcClient.java Class Listing 5-1 EmployeeDataIf.java Class with Web Service Annotations Listing 5-2 EmployeeData.java: An Implementation of a Web Service Interface Listing 5-3 Content of web.xml Listing 5-4 Content of beans.xml Listing 5-5 Content of build.xml for cxf-ws Dynamic Web Project Listing 5-6 A WSDL of a CXF Web Service Application Listing 5-7 EmployeeDataClient.java class Listing 5-8 Content of build.xml for cxf-ws-client Java Project Listing 6-1 Content of weblogic.xml to be Included for cxf-ws.war Web Application Listing 6-2 WSDL for CXF Web Application on Oracle WebLogic Server Listing 7-1 A DDL for Creating Employees table
© Agilent Technologies, Inc. 2012 u.s. 1-800-829-4444 canada: 1-877-894-
Teach with the Best. Learn with the Best. Agilent offers a wide variety of affordable, industry-leading electronic test equipment as well as knowledge-rich, on-line resources —for professors and students. We have 100’s of comprehensive web-based teaching tools, lab experiments, application notes, brochures, DVDs/ CDs, posters, and more. See what Agilent can do for you. www.agilent.com/find/EDUstudents www.agilent.com/find/EDUeducators
Download free eBooks at bookboon.com
Introduction to Web Services with Java
14
Table of Tables
Table of Tables
Table 1. Database Configuration Parameters Table 2. Server Configuration Parameters
Download free eBooks at bookboon.com Click on the ad to read more
Introduction to Web Services with Java
16
Introduction
Nowadays, n-tier Web application architecture is commonly used. In this architecture, middleware or an application server is introduced to connect the Web server and the database more efficiently. The performance of an n-tier application is improved because Web servers, middleware and databases can be hosted by separate machines. Each tier can be replicated for the purposes of load balancing. Security is also improved because data is not stored on the Web or application server, which makes it harder for hackers to gain access into the database where data is stored.
Figure 1-3 An n-tier web architecture
A web and an application servers are often run on the same machine; however, it is best practice to run the database server on a separate machine. In a software development environment, all three servers can be hosted on a single machine. In this book, a server is often refered to a software application.
© Deloitte & Touche LLP and affiliated entities.
© Deloitte & Touche LLP and affiliated entities.
Dis
eloitte & Touche LLP and affiliated entities.
© Deloitte & Touche LLP and affiliated entities.
Discover the truth at www.deloitte.ca/careers
Download free eBooks at bookboon.com
Introduction to Web Services with Java
17
Introduction
1.1 Browsing the Internet
Before the conception of Web 2.0 (around 1999), the basic use of the World Wide Web (WWW) and the Internet was simple and based on the traditional client-server model with older technologies such as Remote Procedure Call (RPC) or Transaction Processing (TP) Monitors or other middleware that permitted programmable clients.
Consider a typical use case of a person browsing the Internet by means of a browser. The Web server in this example serves dynamic HTML pages using Java Server Pages (JSP) technology. In addition, it uses Enterprise Java Bean (EJB) or Plain-Old-Java-Object (POJO). JSP is oriented toward the delivery of webpages for the presentation layer. EJBs or POJOs are usually used for processing business rules. There are thousands of Web applications that use Java/JEE technology.
Figure 1-4 Man-machine interaction
The Internet architecture was originally designed for human users. HTTP protocol was for exchanging documents (Web or HTML pages). HTML was designed for basic graphical user interface (GUI) applications. Computing resources on a web browser are often idle while the user is browsing the Internet. These available resources prompted the idea of providing more robust web browsing experience. In addition, the idea of business-to-business (B2B) data exchange model also became more feasible. Accordingly, the WS architecture was introduced to support this new type of data exchange.
Download free eBooks at bookboon.com Click on the ad to read more
Introduction to Web Services with Java
19
Introduction
Web Service Description Language (WSDL) specifies the service interface and the rules for binding the service consumer and the provider. According to the specification of WSDL 1.1, WSDL is defined as “an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information” (http://www.w3.org/TR/wsdl). WSDL defines how a consumer can interact with a service via a concrete network protocol and message format using eXtended Markup Language (XML).
XML is a profile (subset) of Standard Generalized Markup Language (SGML). SGML is a metalanguage, i.e., a language that describes other languages. Unlike HyperText Markup Language (HTML), which is used to serve static webpages, XML allows the author to create his or her own tags. Thus, XML facilitates the data and document processing functions.
Web Service relies on Simple Object Application Protocol (SOAP) as its transport. As its name implies, SOAP is a lightweight protocol that can be used to exchange structured messages (i.e., XML). SOAP 1. is the latest version. WSDL 1.1 supports SOAP 1.1, HTTP GET/POST, and MIME.
A service can be defined, published and discovered using some type of service registry. Current supporting service registries include electronic business XML (ebXML), Universal Discovery, Description and Integration (UDDI), and Metadata Registry (MDR). UDDI is usually a good idea; however, it is not widely used except in a private network of services.
Download free eBooks at bookboon.com
Introduction to Web Services with Java
20
Introduction
RPC is a powerful technique that provides distributed computing capabilities across a network of machines. RPC is a form of interprocess communication that enables function calls between applications that are located across different (or the same) locations over a network. It is best suited for client-server programming.
Machine A Network^
Machine B callrpc()
return()
Figure 1-5 Remote Procedure Call (RPC)
Web Services can be used to help solve several problems in Enterprise Application Integration (EAI). Integrating existing applications for a business solution is a complex and time-consuming task. Applications that were written in different computer languages, such as C/C++, JAVA, Visual Basic, and FORTRAN, have unique logical interfaces to the external world, which makes the integration of these applications difficult, complex and time-consuming. Applications that are running on different machine architectures, such as SUN, Personal Computer, IBM Mainframes, IBM A/S 400, have unique physical interfaces to the external world. Integrating these applications is also challenging. Applications running on machines that are interconnected through a network are also difficult to integrate. The challenges of EAI arise in three main areas: