Professional Documents
Culture Documents
Web Services
Web Services
Web Services:
JAX-RPC, WSDL, XML Schema, and
SOAP
Client
HTTP response (SOAP body)
Input parameter
names
Return
value
Operations
Parameters
Return values
Communication protocols
Data types
defined using
XML Schema
Operation name
10
11
12
13
Google:
Amazon
S3
14
JWSDP: Server
Application: currency converter
Three operations:
fromDollars
fromEuros
fromYen
15
JWSDP: Server
1.Write service endpoint interface
16
JWSDP: Server
Service endpoint interface
17
JWSDP: Server
Allowable parameter/return value data types
18
JWSDP: Server
Struct for currency converter app (data type
for return values)
19
JWSDP: Server
Service endpoint interface
20
JWSDP: Server
1.Write service endpoint interface
21
JWSDP: Server
Class CurConImpl contains methods, for
example:
22
JWSDP: Server
1.Write service endpoint interface
23
JWSDP: Server
Configuration file input to wscompile to
create server
Namespaces
used in
WSDL
(normally,
unique URLs
at your
Web site)
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey
24
JWSDP: Server
Configuration file for web service
25
JWSDP: Server
Configuration file for web service
Context path
Like
servlet
in
web.xml
Like
servlet-mapping
in
web.xml
Guy-Vincent Jourdan :: CSI 3140 :: based on Jeffrey
26
JWSDP: Server
Also need a minimal web.xml
27
JWSDP: Server
Run jar and wsdeploy to create a Web
Archive (WAR) file converter.war
28
JWSDP: Server
1.Write service endpoint interface
29
JWSDP: Server
Just copy converter.war to Tomcat
webapps directory
30
JWSDP: Server
Testing success:
Visit http://localhost:8080/converter/currency
31
JWSDP: Client
Goal: write a JSP-based client
32
JWSDP: Client
Configuration file input to wscompile to
create client
33
JWSDP: Client
Directory structure (wscompile generates
content of classes and src)
34
JWSDP: Client
Starting point for writing a client (if the
web service author does not explain how):
JWSDP: Client
Obtaining the proxy object:
36
JWSDP: Client
Using the proxy object:
37
JWSDP: Client
Structs will be represented as JavaBeans
classes, regardless of how they are defined on
the server
38
JWSDP: Client
Bean obtaining and calling proxy object:
39
JWSDP: Client
JSP document using the bean:
Call to getExValues()
Call to getEuros()
40
WSDL Example
WSDL
namespaces
Namespaces
specified in
config files
XML Schema NS
41
WSDL Example
Namespace for
data type definitions
(ns2 in rest of document)
Defines struct
using XML
Schema
42
WSDL Example
Data type defined by
XML Schema
Output
messages
(response
data types)
Input
messages
(parameter
lists)
43
WSDL Example
44
WSDL Example
45
WSDL Example
Replaced by server
when WSDL is visited
46
WSDL Example
Summary:
47
XML Schema
How do we send a Java double value to a
web service using XML?
48
XML Schema
XML Schema addresses such questions
of allowed values
How values are represented as strings
49
XML Schema
Built-in data types
Built-in type
50
XML Schema
Built-in data types
51
XML Schema
XML Schema namespace defining built-in
types is called the document namespace
52
XML Schema
53
XML Schema
Mapping from XML Schema data types to
Java:
54
XML Schema
Elements in the document namespace can
declare user-defined data types
Two XML Schema data types:
55
XML Schema
User-defined data types are declared in the
types element of a WSDL
Example: ExchangeValue
56
XML Schema
57
XML Schema
An XML schema is markup that
58
XML Schema
Root element of the markup of an XML schema
is schema
Define data types with elements:
complexType
simpleType
59
XML Schema
One way to define simple types: restrict an
existing simple base type
Base type
60
XML Schema
Built-in types all have facets, that is, aspects that can
be restricted
61
XML Schema
Restricting multiple facets:
62
XML Schema
pattern facet
63
XML Schema
Other simple types
64
XML Schema
Complex type
65
XML Schema
Complex type can be used in placed of
XML DTD content specification
66
XML Schema
67
XML Schema
Instance namespace
68
SOAP
69
SOAP
70
SOAP
Alternate form
71
SOAP
SOAP encoding of arrays in WSDL
72
SOAP
Array in SOAP document
73
SOAP
If SOAP is sent via HTTP, request must
include SOAPAction header field
74
Apache Axis
IBM WebSphere
75
76