web services
DESCRIPTION
Web Services. Web Services - 1. A Web Service is a software component that could be described via WSDL (Web Service Description Language) and is capable of being accessed via standard network protocols , such as SOAP , over HTTP - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/1.jpg)
04/19/23 1
Web Services
![Page 2: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/2.jpg)
04/19/23 2
A Web Service is a software component that could be described via WSDL (Web Service Description Language) and is capable of being accessed via standard network protocols, such as SOAP, over HTTPWeb Services define a platform and language-independent standard based on XML to communicate within distributed systems. SOAP is a lightweight protocol defined by the World Wide Web Consortium (W3C), which defines how to exchange information in a decentralized, distributed systems based on XML.
Ref: http://www.hta-bi.bfh.ch/Projects/wssec/generated/html/glossary.htmlhttp://www.oasis-open.org/committees/wsia/glossary/wsia-draft-glossary-03.htm
Web Services - 1
![Page 3: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/3.jpg)
04/19/23 3
Web Services - 2
Th e we b(H TTP-ba s e d
n e two rk )
we b s e rv ice
we b s e rv ice
we b s e rv ice
clie n t
![Page 4: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/4.jpg)
04/19/23 4
Use of web service:– RPC-based: Java API for XML-based remote
procedure calls (JAX-RPC) defines mappings between Java types and XML types
– Message-based (SOA): SOAP messages– REpresentational State Transfer (REST): “a network
of web pages (a virtual state-machine), where the user progresses through an application by selecting links (state transitions), resulting in the next page (representing the next state of the application) being transferred to the user and rendered for their use.” -- Dr. Roy T. Fielding
Web Services - 3
![Page 5: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/5.jpg)
04/19/23 5
Web service protocol stack
t ra n s po rt
n e two rk
m e s s a g in g
s e rv ice de s cript io n
s e rv ice dis co v e ry
tra n s po rt
n e two rk
m e s s a g in g
s e rv ice de s cript io n
s e rv ice dis co v e ry
a pplica t io n a pplica t io n
![Page 6: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/6.jpg)
04/19/23 6
Web service protocols
t ra n s po rt
n e two rk
m e s s a g in g
s e rv ice de s cript io n
s e rv ice dis co v e ry
a pplica t io n
UD D I (Un iv e rs a l D e s cript io n , D is co v e ry , a n d I n te g ra t io n )
W S D L (W e b S e rv ice D e s cript io n L a n g u a g e )
X M L , S O A P (S im ple O bje ct A cce s s Pro to co l)
TC P, H TTP, S M TP, J a bbe r
I P
![Page 7: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/7.jpg)
04/19/23 7
SOAPSOAP is a protocol, which applies XML for message exchange in support of remote method calls over the Internet.Compared to Remote Method Invocation (RMI) or CORBA-based facilities: – SOAP is web-based or “wired” and hence is not subject
to firewall restrictions– is Language-independent– provides just-in-time service integration--as requesters
use a service broker (e.g., UDDI--Universal Description, Discovery, and Integration ) to find services, the discovery will take place dynamically.
![Page 8: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/8.jpg)
04/19/23 8
Remote Procedure Call using HTTP
we bs e rv e r
we bclie n t
s e rvi ceobje ct
H TTP re qu e s t
H TTP re s po n s e
m e t h o d n a m e ,p a r a m e t e r l i s t
r e t u r n va l u e
![Page 9: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/9.jpg)
04/19/23 9
SOAP Messages
m e s s a g e bo dy
S O A P bo dy
h e a de r blo ck
h e a de r blo ck
S O A P h e a de r
S O A P e n v e lo pe
op
tio
na
lr
eq
uir
ed
![Page 10: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/10.jpg)
04/19/23 10
< s o a p:En v e lo pe x m ln s : s o a p= 'h t tp: //www.w3 .o rg /2 0 0 1 /1 0 /s o a p-e n v e lo pe '> < s o a p:H e a de r>
< - - H e a de rs g o h e re - ->
< /s o a p:H e a de r> < s o a p:B o dy >
< - - R e qu e s t g o e s h e re - ->
< /s o a p:B o dy >< /s o a p:En v e lo pe >
S o u rce : h t tp: // www.x m l.co m /
SOAP Messages
![Page 11: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/11.jpg)
04/19/23 11
Example of a SOAP message< s o a p:En v e lo pe x m ln s : s o a p= 'h t tp: //www.w3 .o rg /2 0 0 1 /1 0 /s o a p-e n v e lo pe '>
< s o a p:H e a de r> < h :L o g x m ln s :h = 'h t tp: //e x a m ple .o rg /cv s /lo g g in g '> < tra ce > 4 < /t ra ce > < /h :L o g > < h : PS e rv e r x m ln s :h = 'h t tp: //e x a m ple .o rg /cv s /ps e rv e r' s o a p: m u s tUn de rs ta n d= 't ru e ' > < u s e rn a m e > a n o n cv s @ e x a m ple .o rg < /u s e rn a m e > < pa s s wo rd> a n o n cv s < /pa s s wo rd> < /h : PS e rv e r> < /s o a p:H e a de r>
< s o a p:B o dy > < m :C h e ck o u t x m ln s :m = 'h t tp: //e x a m ple .o rg /cv s '> < s o u rce > /x m l/s o a p/we bs e rv ice s /cv s < /s o u rce > < re v is io n > 1 .1 < /re v is io n > < de s t in a t io n > /e tc/u s r/m a rt in g /s o u rce /x m l< /de s t in a t io n > < /m :C h e ck o u t> < /s o a p:B o dy >< /s o a p:En v e lo pe >
s o u rce : h t tp: //www.x m l.co m
![Page 12: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/12.jpg)
04/19/23 12
A SOAP Message with a RPCsource: (http://www.soaprpc.com/tutorials/) A Busy Developer’s Guide To Soap1.1
<SOAP-ENV:Envelope SOAP-ENV:encodingStyle= "http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance">
<SOAP-ENV:Body> <m:getStateName xmlns:m="http://www.soapware.org/"> <statenum xsi:type="xsd:int">41</statenum> </m:getStateName> </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
![Page 13: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/13.jpg)
04/19/23 13
An Example SOAP Requestsource: (http://www.soaprpc.com/tutorials/) A Busy Developer’s Guide To Soap1.1
< ? x m l v e rs io n = " 1 .0 " ? >< S O A P- ENV :En v e lo pe S O A P- ENV :e n co din g S ty le = " h t tp: //s ch e m a s .x m ls o a p.o rg /s o a p/e n co din g /"x m ln s :S O A P- ENC = " h t tp: //s ch e m a s .x m ls o a p.o rg /s o a p/e n co din g /"x m ln s :S O A P- ENV = " h t tp: //s ch e m a s .x m ls o a p.o rg /s o a p/e n v e lo pe /"x m ln s :x s d= " h t tp: //www.w3 .o rg /1 9 9 9 /X M L S ch e m a "x m ln s :x s i= " h t tp: //www.w3 .o rg /1 9 9 9 /X M L S ch e m a - in s ta n ce " >
< S O A P- ENV :B o dy > < m :g e tS ta te Na m e x m ln s :m = " h t tp: //www.s o a pwa re .o rg /" > < s ta te n u m x s i: ty pe = " x s d: in t" > 4 1 < /s ta te n u m > < /m :g e tS ta te Na m e > < /S O A P- ENV :B o dy > < /S O A P- ENV :En v e lo pe >
pa ra m e te r o f ty pe in t a n d v a lu e 4 1
pro ce du ren a m e
n a m e o f s e rv e r
![Page 14: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/14.jpg)
04/19/23 14
Response example source: (http://www.soaprpc.com/tutorials/) A Busy Developer’s Guide To Soap1.1
< ? x m l v e rs io n = " 1 .0 " ? >< S O A P- ENV :En v e lo pe S O A P- ENV :
e n co din g S ty le = " h t tp: //s ch e m a s .x m ls o a p.o rg /s o a p/e n co din g /"x m ln s :S O A P- ENC = " h t tp: //s ch e m a s .x m ls o a p.o rg /s o a p/e n co din g /"x m ln s :S O A P- ENV = " h t tp: //s ch e m a s .x m ls o a p.o rg /s o a p/e n v e lo pe /"x m ln s :x s d= " h t tp: //www.w3 .o rg /1 9 9 9 /X M L S ch e m a "x m ln s :x s i= " h t tp: //www.w3 .o rg /1 9 9 9 /X M L S ch e m a - in s ta n ce " >
< S O A P- ENV :B o dy > < m :g e tS ta te Na m e R e s po n s e x m ln s :m = " h t tp: //www.s o a pwa re .o rg /" > < R e s u lt x s i: ty pe = " x s d:s trin g " > S o u th D a k o ta < /R e s u lt> < /m :g e tS ta te Na m e R e s po n s e > < /S O A P- ENV :B o dy >< /S O A P- ENV :En v e lo pe >
n a m e o f s e rv e r
r e tu r n ed v a lu e
pro ce du re n a m e
![Page 15: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/15.jpg)
04/19/23 15
Example of a SOAP message for an Error RPC response
http://www.soapware.org/bdg
< ? x m l v e rs io n = " 1 .0 " ? >< S O A P- ENV :En v e lo pe S O A P- ENV :
e n co din g S ty le = " h t tp: //s ch e m a s .x m ls o a p.o rg /s o a p/e n co din g /"x m ln s :S O A P- ENV = " h t tp: //s ch e m a s .x m ls o a p.o rg /s o a p/e n v e lo pe /"x m ln s :x s d= " h t tp: //www.w3 .o rg /1 9 9 9 /X M L S ch e m a "x m ln s :x s i= " h t tp: //www.w3 .o rg /1 9 9 9 /X M L S ch e m a - in s ta n ce " >
< S O A P- ENV :B o dy > < S O A P- ENV :Fa u lt> < fa u lt co de > S O A P- ENV :C lie n t< /fa u lt co de > < fa u lt s t r in g > C a n 't ca ll g e tS ta te Na m e be ca u s e th e re a re t o o m a n y pa ra m e te rs . < /fa u lt s t r in g > < /S O A P- ENV :Fa u lt> < /S O A P- ENV :B o dy >< /S O A P- ENV :En v e lo pe >
![Page 16: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/16.jpg)
04/19/23 16
HTTP and SOAP RPC Requestsource: (http://www.soaprpc.com/tutorials/) A Busy Developer’s Guide To Soap1.1
A SOAP message can be used to transport a SOAP remote procedure request/response, as follows: POST /examples HTTP/1.1
User-Agent: Radio UserLand/7.0 (WinNT)Host: localhost:81Content-Type: text/xml; charset=utf-8Content-length: 474SOAPAction: "/examples"<blank line>
<text for SOAP message>
![Page 17: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/17.jpg)
04/19/23 17
An HTTP request that carries a SOAP RPC request source: (http://www.soaprpc.com/tutorials/) A Busy Developer’s Guide To Soap1.1
POST /examples HTTP/1.1User-Agent: Radio UserLand/7.0 (WinNT)Host: localhost:81Content-Type: text/xml; charset=utf-8Content-length: 474SOAPAction: "/examples"
<?xml version="1.0"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle=
"http://schemas.xmlsoap.org/soap/encoding/" xmlns: SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns: SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"><SOAP-ENV:Body> <m:getStateName xmlns:m="http://www.soapware.org/"> <statenum xsi:type="xsd:int">41</statenum> </m:getStateName> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
![Page 18: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/18.jpg)
04/19/23 18
An HTTP request that carries a SOAP RPC responsesource: (http://www.soaprpc.com/tutorials/) A Busy Developer’s Guide To
Soap1.1 HTTP/1.1 200 OK
Connection: closeContent-Length: 499Content-Type: text/xml; charset=utf-8Date: Wed, 28 Mar 2001 05:05:04 GMTServer: UserLand Frontier/7.0-WinNT
<?xml version="1.0"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"> <SOAP-ENV:Body> <m:getStateNameResponse xmlns:m="http://www.soapware.org/"> <Result xsi:type="xsd:string">South Dakota</Result> </m:getStateNameResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
![Page 19: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/19.jpg)
04/19/23 19
An HTTP request that carries a SOAP Error messagesource: (http://www.soaprpc.com/tutorials/) A Busy Developer’s Guide To Soap1.1
HTTP/1.1 500 Server ErrorConnection: closeContent-Length: 511Content-Type: text/xml; charset=utf-8Date: Wed, 28 Mar 2001 05:06:32 GMTServer: UserLand Frontier/7.0-WinNT
<?xml version="1.0"?><SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"> <SOAP-ENV:Body> <SOAP-ENV:Fault> <faultcode> SOAP-ENV:Client </faultcode> <faultstring> Can't call getStateName because there are too many parameters.</faultstring> </SOAP-ENV:Fault> </SOAP-ENV:Body> </SOAP-ENV:Envelope>
![Page 20: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/20.jpg)
04/19/23 20
Advantages of web serviceshttp://en.wikipedia.org/wiki/Web_service#Advantages_of_web_services
Web services provide interoperability between various software applications running on disparate platforms. Web services use open standards and protocols. Protocols and data formats are text-based where possible, making it easy for developers to comprehend. By utilizing HTTP, web services can work through many common firewall security measures without requiring changes to the firewall filtering rules. Other forms of RPC may more often be blocked. Web services allow software and services from different companies and locations to be combined easily to provide an integrated service.
![Page 21: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/21.jpg)
04/19/23 21
Disadvantages of Web Serviceshttp://en.wikipedia.org/wiki/Web_service
Lacks of standard features, such as transactions, while comparing to other open standards, such as CORBA.
Poor performance due to using of XML text-formats.
![Page 22: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/22.jpg)
04/19/23 22
Example of Web Service Request
<?xml version="1.0" encoding="UTF-8" ?> <SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:q0="http://wsv.mci.com/ETECapability" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body> <q0:BuildingID>rvc</q0:BuildingID> </SOAP-ENV:Body></SOAP-ENV:Envelope>
![Page 23: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/23.jpg)
04/19/23 23
<?xml version="1.0" encoding="utf-8" ?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Header />
<soapenv:Body><ETESitesForBuilding xmlns="http://wsv.mci.com/ETECapability"> <BuildingID>rvc</BuildingID> <OnNet>1</OnNet> <BuildingStatus>active</BuildingStatus> <BuildingServiceType>fiber</BuildingServiceType>
<Sites> <SiteCode>80</SiteCode> <SiteCLLI>CHCGILTOH44</SiteCLLI>
<PortTypes> <EquipmentType>ee4000</EquipmentType> <PortType>10/100</PortType> <PortType>GigE</PortType> </PortTypes> <Dedicated>0</Dedicated>
<CSiteID xsi:nil="true" /> <ColloRestrictedFlag>0</ColloRestrictedFlag> <SiteStatus>active</SiteStatus> <SiteType>node</SiteType>
</Sites></ETESitesForBuilding></soapenv:Body></soapenv:Envelope>
Example of Web Service Response
![Page 24: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/24.jpg)
04/19/23 24
SOAP Packagessource: http://www.soapuser.com
Apache SOAP for JavaApache Axis for JavaIdoox WASP for C++Microsoft SOAP Toolkit (part of the .net framework)SOAP::Lite for Perl
Demo: http://cs1.cs.gmu.edu:8081/admin/index.html
![Page 25: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/25.jpg)
04/19/23 25
Apache SOAP
Allows clients and services to be written in Java
Part of the Apache-XML project (http://xml.apache.org/)
SOAP package downloadable: http://xml.apache.org/dist/soap/
Installation instruction:
http://www.xmethods.com/gettingstarted/apache.html
![Page 26: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/26.jpg)
04/19/23 26
Apache SOAP installation
% T O M C AT _ HO M E %
w eb ap p s
s o ap
W EB- I N F
c las s es
o n jav a
C alc S er v ic e . jav aC alc S er v ic e . c las sD ep lo y m en tD es c r ip to r .x m l
s o ap .w ar
s o ap
C :
s o ap - 2 _ 2
lib
x er c es , ja r m ail. ja r s o ap . ja r ac tiv a tio n . ja r
![Page 27: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/27.jpg)
04/19/23 27
Classpath setting
set CLASSPATH=C:\soap\soap-2_2\lib\xerces.jar;
C:\jdk1.3\bin;
C:\jdk1.3\lib\tools.jar;
C:\soap\soap-2_2\lib\mail.jar;
C:\soap\soap-2_2\lib\soap.jar;
C:\soap\soap-2_2\lib\activation.jar;
C:\tomcat\lib\servlet.jar;
.;
![Page 28: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/28.jpg)
04/19/23 28
Writing a Client Application using Apache SOAPsource: http://www.xmethods.com/gettingstarted/apache.html
Classpath The CLASSPATH environment variable should have both the "soap.jar" and "xerces.jar" JAR files included. Importing packages For basic SOAP method invocation:// Required due to use of URL class , required by Call class import java.net.*;
// Required due to use of Vector class import java.util.*;
// Apache SOAP classes used by client import org.apache.soap.util.xml.*; import org.apache.soap.*; import org.apache.soap.rpc.*;
![Page 29: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/29.jpg)
04/19/23 29
Ready-made SOAP Services
A number of SOAP ready-made services are available at http://www.xmethods.com/
XMethods Service Weather Temperature ID8 Service Owner:xmethods.net Contact Email:[email protected] Service Description:Current temperature in a
given U.S. zipcode region. SOAP Implementation:Apache SOAP
![Page 30: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/30.jpg)
04/19/23 30
Sample SOAP service
An aly ze W S D L | View R P C P r o f ile | h t tp :/ /w w w .x m eth o d s .n e t /s d /2 0 0 1 /T em p era tu r eS erv ic e .w s d lX M eth o d s I D 8S er v ic e O w n er : x m eth o d s .n e tC o n tac t Em ail: s u p p o r t@ x m eth o d s .n e tS er v ic e Ho m e P ag e:D es c r ip tio n : C u r r en t tem p era tu r e in a g iv en U.S . z ip c o d e r eg io n .S O AP Im p lem en ta tio n : Ap ac h e S O AP
W e a the r - T e m p e ra tu re
Found at http://www.xmethods.com
![Page 31: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/31.jpg)
04/19/23 31
RPC Profile for Service
R PC Pro f ile fo r S e rv ice " W e a th e r - Te m pe ra tu re "
M e th o d Na m e g e tTe m pEn dpo in t UR L h t tp: //s e rv ice s .x m e th o ds .n e t :8 0 /s o a p/s e rv le t /rpcro u te rS O A PA ct io nM e th o d Na m e s pa ce UR I u rn :x m e th o ds -Te m pe ra tu reI n pu t Pa ra m e te rs z ip c o d e s t rin g
O u tpu t Pa ra m e te rs r e tu r n f lo a t
See sample: TempClient.java
![Page 32: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/32.jpg)
04/19/23 32
Client program samples
See samples in client folder:– TempClient.java– StockQuoteClient.java– CurrencyClient.java
![Page 33: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/33.jpg)
04/19/23 33
SOAP data types
SOAP Data Types http://www.sdc.iup.edu/outreach/spring2002/webservices/datatypes.html
Uses XML Schema data types
Primitive Types
string, boolean, decimal, float, double, duration, dateTime, time, date, gYearMonth, gYear, gMonthDay, gDay, gMonth, hexBinary, base64Binary, anyURI, QName, NOTATION
![Page 34: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/34.jpg)
04/19/23 34
SOAP data types
Derived Types
Simple types (derived from a single primitive type)* integer is derived from decimal* int (-2147483648 <= int <= 2147483647) is derived from long which is derived from integer * 5-digit zip code can be derived from int* may use regular expressions to specify derived types, such as ([A-Z]){2,3}-\d{5}
![Page 35: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/35.jpg)
04/19/23 35
Complex Type
Complex types (struct or array)Struct example<instructor> <firstname xsi:type="xsd:string">Ed</firstname>
<lastname xsi:type="xsd:string">Donley</lastname> </instructor>
Array example <mathcourses xsi:type=
"SOAP-ENC:Array" SOAP ENC:arrayType="se:string[3]"> <se:string>10452C</se:string> <se:string>10454C</se:string> <se:string>11123T</se:string>
</mathcourses>
![Page 36: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/36.jpg)
04/19/23 36
Creating Web Services (server-side SOAP)
O'Reilly Network: Using SOAP with Tomcat http://www.onjava.com/pub/a/onjava/2002/02/27/tomcat.htm
Apache SOAP allows you to create and deploy a SOAP web service.Some jar files must be installed, and must be accessible by the CLASSPATH.
Algorithm:1. Develop a class for providing the service.2. Create a deployment descriptor in XML.3. Deploy the service with the service manager.
![Page 37: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/37.jpg)
04/19/23 37
The Apache SOAP service manager
The service manager is itself implemented as a SOAP service.
To see what services are deployed on your system:
java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter list
To deploy a service:
java org.apache.soap.server.ServiceManagerClient http://localhost:8080/soap/servlet/rpcrouter deploy foo.xml
![Page 38: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/38.jpg)
04/19/23 38
Creating a SOAP ServiceO'Reilly Network: Using SOAP with Tomcat [Feb. 27, 2002]http://www.onjava.com/pub/a/onjava/2002/02/27/tomcat.html
A SOAP service can be just about any Java class that exposes public methods for invocation.
The class does not need to know anything about SOAP, or even that it is being executed as a SOAP service.
The method parameters of a SOAP service must be serializable. The available types that can be used as SOAP service parameters are shown in the next slide
![Page 39: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/39.jpg)
04/19/23 39
SOAP Service Parameter TypesAll Java primitive types and their corresponding wrapper classes
Java arrays
java.lang.String
java.util.Date
java.util.GregorianCalendar
java.util.Vector
java.util.Hashtable
java.util.Map
![Page 40: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/40.jpg)
04/19/23 40
SOAP Service Parameter Typesjava.math.BigDecimal javax.mail.internet.MimeBodyPart
java.io.InputStream
javax.activation.DataSource
javax.activation.DataHandler
org.apache.soap.util.xml.QName
org.apache.soap.rpc.Parameter
java.lang.Object (must be a JavaBean)
![Page 41: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/41.jpg)
04/19/23 41
Sample SOAP Service Implementations
TempService: A temperature service
Exchange: currency exchange service and client
Ref: http://ise.gmu.edu/~yhwang1/SWE622/Sample_Codes/chapter11/SOAP/
![Page 42: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/42.jpg)
04/19/23 42
Sample SOAP Service Class// A sample SOAP service class// ref: http://www.onjava.com/pub/a/onjava/2002/02/27/tomcat.html
package onjava;public class CalcService { public int add (int p1, int p2) { return p1 + p2; }
public int subtract (int p1, int p2) { return p1 - p2; }}
![Page 43: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/43.jpg)
04/19/23 43
Deployment Descriptor
<isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
id="urn:onjavaserver"> <isd:provider type="java" scope="Application" methods="add subtract"> <isd:java class="onjava.CalcService"/> </isd:provider>
<isd:faultListener>org.apache.soap.server.DOMFaultListener </isd:faultListener></isd:service>
![Page 44: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/44.jpg)
04/19/23 44
Sources of Information
Programming Web Services with SOAP, by Snell et al, O’ReillySOAP Tutorial, http://www.w3schools.com/soap/default.aspSoapRPC.com: Tutorials, http://www.soaprpc.com/tutorials/--Developer’s Guide To Soap1.1DaveNet : XML-RPC for Newbies, http://davenet.userland.com/1998/07/14/xmlRpcForNewbiesSoapRPC.com: Other resources, http://www.soaprpc.com/resources/
![Page 45: Web Services](https://reader035.vdocuments.us/reader035/viewer/2022062517/56812ed7550346895d947784/html5/thumbnails/45.jpg)
04/19/23 45
Summary
SOAP is a protocol that makes use of HTTP requests and responses to effect remote method calls to web services.
A SOAP method call is encoded in XML and is embedded in an HTTP request
The return value of a method call is likewise embedded and encoded in an HTTP response
A number of SOAP APIs are available for programming web services and client method calls. The Apache API was introduced.