Download presentation
Presentation is loading. Please wait.
Published byRalph Pearson Modified over 9 years ago
1
AUTHOR: HAI NGUYEN CREATED DATE: 04/11/2008 Web Service Introduction
2
Agenda Web Service Introduction What is Web Service? Why Web Service? XML and Schema Web Service: Style of Use Web Service interactions Web Service elements SOAP WSDL Web service development
3
WHAT IS WEB SERVICE? WHY WEB SERVICE? Web Service Introduction
4
What is Web Service A Software system designed to support interoperable Machine to Machine interaction over network They are the Web APIs are hosting in machine that can be invoked by remote machine The basic platform of Web services is Http + XML
5
Why web service? Interoperability is the highest priority Simple use
6
XML SCHEMA XML and Schema
7
XML All of you already knows XML! It is very popular now and be used everywhere We only talk some advance feature of XML
8
XML namespaces Namespace is used to solve conflicts between XML element Example 1: Conflicts of Address information Nextss 123 ABC HCM VN Google 123 ABC ABC xxx-xxx-xxxx
9
XML namespaces The namespace is defined by the xmlns attribute in the start tag of an element. The namespace declaration has the following syntax. xmlns:prefix="URI".
10
XML namespaces Example 2: Solve conflicts in data Nextss 123 ABC HCM VN Google 123 ABC ABC xxx-xxx-xxxx
11
XML encoding XML can contains non Ascii characters like Vietnamese language The encoding errors can happen in case: XML contains non ASCII characters, and the file was saved as single-byte ANSI (or ASCII) with no encoding specified. Encoding specified in XML is invalid: XML file was saved as double-byte Unicode (or UTF-16) with a single-byte encoding (Windows-1252, ISO-8859-1, UTF-8) specified.
12
XML SCHEMA XML and Schema
13
XML Schema XML Schema is an XML-based to describe the structure of XML document The XML Schema language is also referred to as XML Schema Definition (XSD)
14
XML Schema XML Schema defines: Elements that can appear in a document Attributes that can appear in a document Which elements are child elements The order of child elements The number of child elements Whether an element is empty or can include text Data types for elements and attributes Default and fixed values for elements and attributes
15
XML Schema Example: Xml file “Note.xml”: Tove Jani Reminder Don't forget me this weekend!
16
XML Schema An XML Schema “note.xsd”:
17
XML Schema Validate XML by using XML Schema <note xmlns="http://www.nextss.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.nextss.com note.xsd"> Tove Jani Reminder Don't forget me this weekend!
18
REMOTE PROCEDURE CALLS (RPC) RESOURCE ORIENTED MESSAGING Web Service: Styles of Use
19
Style Of Uses
20
Web Services RPC RPC Web services present a distributed function (or method) call interface that is familiar to many developers. Typically, the basic unit of RPC Web services is the WSDL operation. SOAP using a synchronous RPC programming approach and, typically, generated 'skeletons/stubs' and some sort of Object-to-XML marshalling technology
21
Web Service Resource Oriented A client-server based resource-oriented pattern where the server-side provides a representation of a set of resources (often hierarchical) and exposes Create, Read, Update and Delete capabilities for these resources to client programs. REST or 'RESTful Web Services' or ROA, re-using World-Wide-Web based approaches and standards like HTTP and URIs
22
Web Service Messaging Messages or documents are passed asynchronously between peer systems in either, but not always both, directions. SOAP using an asynchronous Message/Document passing approach where invariably the documents are defined by schemas and, often, the use of message-level (rather than transport-level) security elements is required
23
RPC INTERACTIONS DOCUMENT INTERACTIONS Web Service Interactions
24
RPC Interactions
25
The web service is viewed by the consumer as a single logical application or component with encapsulated data, where the WSDL described by the publicly-exposed interface The messages directly map onto input and output parameters of the procedure calls or operations
26
RPC INTERACTIONS DOCUMENT INTERACTIONS Web Services Interactions
27
Document Interactions
28
The service consumer interacts with the service using documents that are meant to be processed as complete entities These exchanged documents typically take the form of XML, which is defined by a commonly agreed upon schema between the service provider and service consumer The exchanged document represents a complete unit of information and may be completely self- describing
29
SOAP WSDL Web Service Elements
30
SOAP SOAP stands for Simple Object Access Protocol SOAP is the transport method SOAP is the format of sending message SOAP is platform and language independent SOAP is XML-based format SOAP is simple and extensible
31
SOAP Skeleton of SOAP message <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">.........
32
SOAP WSDL Web Service Elements
33
WSDL WSDL stands for Web Services Description Language WSDL is written in XML WSDL is an XML document WSDL is used to describe Web services WSDL is also used to locate Web services
34
WSDL - Types - Message - PortType - Binding WSDL Document Structure The operations performed by the web service The messages used by the web service The data types used by the web service The communication protocols used by the web service
35
WSDL Types The element defines the data type that are used by the web service. For maximum platform neutrality, WSDL uses XML Schema syntax to define data types.
36
WSDL Messages The element defines the data elements of an operation. Each message can consist of one or more parts. The parts can be compared to the parameters of a function call in a traditional programming language.
37
WSDL Ports The element defines the data elements of an operation. Each message can consist of one or more parts. The parts can be compared to the parameters of a function call in a traditional programming language.
38
WSDL Ports Operation Types One-wayThe operation can receive a message but will not return a response Request-responseThe operation can receive a request and will return a response Solicit-responseThe operation can send a request and will wait for a response NotificationThe operation can send a message but will not wait for a response
39
SOAP Bindings The element defines the message format and protocol details for each port. Example: <soap:binding style="document“ transport=http://schemas.xmlsoap.org/soap/http>http://schemas.xmlsoap.org/soap/http
40
SOAP Bindings The soap:binding element has two attributes - the style attribute and the transport attribute. The style attribute can be "rpc" or "document". The transport attribute defines the SOAP protocol to use. The operation element defines each operation that the port exposes. For each operation the corresponding SOAP action has to be defined. You must also specify how the input and output are encoded.
41
SOAP Bindings A WSDL SOAP binding can be either a Remote Procedure Call (RPC) style binding or a document style binding. A SOAP binding can also have an encoded use or a literal use. There are four style/use models: RPC/encoded RPC/literal Document/encoded Document/literal
42
SOAP Bindings Example We have the service interface @WebService(name="HelloWorld“, targetNamespace="http://spring.demo/") @SOAPBinding(style=SOAPBinding.Style.DOCUMENT, use=SOAPBinding.Use.LITERAL) public interface HelloWorld { String sayHi(@WebParam(targetNamespace="http://spring.demo/", name="text")String text); }
43
SOAP Bindings Example WSDL file for service interface:
44
SOAP Bindings Example SOAP Request with RPC/Encoded Format Viet Nam SOAP Response with RPC/Encoded Format Hello Viet Nam
45
SOAP Bindings Example: RPC/Literal WSDL with RPC/Literal Format
46
SOAP Bindings Example: RPC/Literal SOAP Request with RPC/Literal Format Viet Nam SOAP Response with RPC/Literal Format Hello Viet Nam
47
SOAP Bindings Example: Document/Literal WSDL file for Document/Literal Format
48
SOAP Bindings Example: Document/Literal SOAP Request with Document/Literal Format Viet Nam SOAP Response with Document/Literal Format Hello Viet Nam
49
Decision on the formatting style Validate business documents: service is accepting or returning a complex XML structure, a document style is better suited, since the XML can be validated against the schema prior to calling the service. Performance and memory limitations: Marshalling and un-marshalling parameters to XML in memory can be an intensive process
50
Decision on the formatting style Interoperability: using RPC style can causes interoperability issues across platforms. To facilitate interoperability, the WS-I Basic Profile limits the use of the encoding (RPC-encoded or document- encoded) and encourages a literal formatting (document-literal or RPC-literal style)
51
TWO APPROACHES OF DEVELOPING SERVICES WEB SERVICE DEBUGGING Web Service Development
52
Two approaches of developing web service - - Code first - - WSDL first Code first: write the business code and web service engine will generate the WSDL by itself at compile time or runtime WSDL first: write the WSDL first before writing interface and business code for service. Note: Each approach has both advantages and disadvantages!
53
Code First Advantage: Time of writing code is reduced. Developers mostly focus on code only. Disadvantage: Less interoperable among platforms/programming language! Example: -.NET client program could not invoke the web service written in Java language - Java client program (use Axis framework) could not invoke web service written in Java language (use Cxf framework)
54
WSDL First Advantage: More interoperable among platforms/programming language! Disadvantage: Time of development is greater than Code first approach (includes manual update WSDL while service change)
55
Web Service Debugging Log files Debugging Tools TCP Monitor: WSMonitor: https://wsmonitor.dev.java.net/https://wsmonitor.dev.java.net/ Tcpmon: https://tcpmon.dev.java.net/https://tcpmon.dev.java.net/ Wireshark: http://www.wireshark.org/http://www.wireshark.org/ Eclipse IDE Functional Testing: SOAP UI: http://www.pushtotest.com/http://www.pushtotest.com/ PushToTest: http://www.pushtotest.com/http://www.pushtotest.com/
56
References [1]. Web service - http://en.wikipedia.org/wiki/Web_service http://en.wikipedia.org/wiki/Web_service [2]. Web Service Tutorial - http://www.w3schools.com/webservices/default.asp http://www.w3schools.com/webservices/default.asp [3]. SOAP Tutorial - http://www.w3schools.com/soap/default.asp http://www.w3schools.com/soap/default.asp [4]. WSDL Tutorial - http://www.w3schools.com/wsdl/default.asp http://www.w3schools.com/wsdl/default.asp [5]. Russel, Butek - Which style of WSDL should I use? http://www.ibm.com/developerworks/webservices/libra ry/ws-whichwsdl/ http://www.ibm.com/developerworks/webservices/libra ry/ws-whichwsdl/
57
References [6]. Sameer Tyagi - Patterns and Strategies for Building Document Based Web Services – http://java.sun.com/developer/technicalArticles/xml/ja xrpcpatterns/ http://java.sun.com/developer/technicalArticles/xml/ja xrpcpatterns/ [7]. Sameer Tyagi - Interoperability With Patterns and Strategies for Document Based Web Services - http://java.sun.com/developer/technicalArticles/xml/ja xrpcpatterns2/index.html http://java.sun.com/developer/technicalArticles/xml/ja xrpcpatterns2/index.html [8]. Paul Done - Web Services: RPC, REST and Messaging - http://dev2dev.bea.com/blog/pdone/archive/2008/02/ web_services_rp.html http://dev2dev.bea.com/blog/pdone/archive/2008/02/ web_services_rp.html
58
References [10], Representational State Transfer - http://en.wikipedia.org/wiki/Representational_Stat e_Transfer http://en.wikipedia.org/wiki/Representational_Stat e_Transfer
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.