Advanced Protocols 2004
Motivation
• Exchanging data over Networks
– WebServices • Network Services provided over http –”Wired
Services”• A New way to build Network Applications
from distributed components that are language and platform independent
– SOAP• Simple,flexible and highly extensible • It is a Network Application Protocol
Advanced Protocols 2004
My Intrest in this protocol
• Enterprise Application Server – Weblogic Server (BEA) –past 2 yrs– .Net Frame Work (Microsoft)- past 6 months– Websphere (IBM)- Idea
• I used XML in these applications and latest techniques WSDL or SOAP consist some knowledge gaps.– Gaps: WSDL and SOAP reusability
functions.
Advanced Protocols 2004
History
Communication protocol over WWW – http-s (Over a Secure Socket) 443(port)
– 1991 http(V0.9) Tim Brener’s& Lee – 1996 http 1.0– 1999 http 1.1 (80:Port)
– XML – V1.0 Feb 10 1998 project of W3C
– SOAP – May 2000 – Dave Winner,Don Box and Bob Atkinson
» Microsoft & IBM filed to W3C» Later on all major Companies are approved» SOAP 1.1/SOAP 1.2
Advanced Protocols 2004
WebServices
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
•New bread Web application•Self-contained,self-describing,
Modular applications that can be Published, located and invoked across the web ~~IBM Web service tutorial
Advanced Protocols 2004
Webservice Software Components
• A Webservice is a message-based network service
• A server which provides a web service must be capable of “sending and receiving messages using some combination of standard Internet protocols”
Service Provider
Service Broker Service Requestor
”Server”
”Naming Service” ”client”
Service Provider
Service Broker Service Requestor
”Server”
Publish(WSDL)Bind(SOAP)
Find(UDDI)
•SOAP & WSDL- W3 Standards•UDDI – OASIS Standard
Advanced Protocols 2004
Just-in-time Integration• Network services can be integrated
dynamically, on an as-needed basis.
• SunMicro’s jini is a framework that supports the idea.
• Network services are registered with a service registry; a service consumer/client looks up the registry to fulfill its needs.
• The binding of a client to the service can occur at runtime.
a pplica t io nlo g ic
s e rv icepro x y
s e rv icelis t e n e r
s e rv icere qu e s t
Advanced Protocols 2004
WebService Protocol Stack &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
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
UDDI(Universal Description, discorvery And Integration )
WSDL(Web Service Defination Language)
XML,SOAP
TCP,HTTP,SMTP,FTP
IP
Advanced Protocols 2004
Basic webservice Usage Scenario
(manual)web Service Lookup
Reads ParametersFunctions
Write clientApplication
Webservice Repository
(UDDI)
Web Service Provider
Publish web Service
1 Register WSDLfile(manually)
2 http Get
3 WSDL file
4 SOAP Req
5 SOAP Resp
Advanced Protocols 2004
Web Services Implementation
HttpServer
SoapServer
Applicationserver
Web Service Provider
Requestor
Soap Client
Soap Messages(http transport)
• Application Server (Web service-enabled)
Provides implementation of services and exposes it through WSDL/SOAP
implementation in Java,J2EE,.Net(C#)
•Soap Server – implements Soap Protocol
•Http Server - Standard web server
•Soap Client – implements Soap Protocol on client Site
Advanced Protocols 2004
Corba Vs Webservices (1/2)
CORBA STACK WEB SERVICES STACK
IDL WSDL
CORBA(Naming Services) SOAP Messaging
CORBA (Stub/Skelton) XML Unicode encoding
CDR binary encoding XML Unicode encoding
GIOP/IIOP HTTP
TCP/IP TCP/IP
~Both technologies lies on TCP/IP~Deviate at Transport Layer where webservice choose web protocol and CORBA is proprietary to standard
Advanced Protocols 2004
Corba Vs WebServices (2/2)Feature Object Model Web Service
Data Model Object Model SOAP message exchange model
Client-Server Computing
Tight Coupling(Common State)
Loose Coupling
Type System IDL XML
Location Transperancy
Object References URL
Parameter Passing By reference /Value By Value Only
Type Checking Static+ runtime Runtime only
Service Discovery Naming /Trading Service
UDDI
Serialization Built on ORB Choosen by user
Advanced Protocols 2004
SOAP (Simple Object Access Protocol)
• SOAP is a protocol which applies XML for message exchange in support of remote method calls over the Internet.
• Light Weight messaging framework based on XML
• Supports simple messaging and RPC• Platform independent and language
independent
Advanced Protocols 2004
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
Advanced Protocols 2004
SOAP Messages
Soap Message Object with No Attachments
SOAP Message
Envelope: top element of XML message
Header: General Information on message such as security
Body: data exchanged
Fault : Error messages
http://www.w3.org/2001/12/soap-envelope
Advanced Protocols 2004
An XML –encoded SOAP RPC<?xml version="1.0"?> <soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Header> ...Headers here ...
</soap:Header><soap:Body> <soap:Fault>
... ...Request goes here... ... </soap:Fault> </soap:Body></soap:Envelope>
Name Space
Encoding Style
Advanced Protocols 2004
A SOAP Message that contains a RPC
• <?xml version="1.0"?> <soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
<soap:Body> <m:GetPrice
xmlns:m="http://www.w3schools.com/prices"> <m:Item>Apples</m:Item>
</m:GetPrice> </soap:Body></soap:Envelope>
Source at (W3schools.com)
Procedure Name
Server NameParameters
Advanced Protocols 2004
Example of a SOAP Request• <?xml version="1.0" encoding="UTF-8"
standalone="yes"?><e:Envelope
xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:e="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i="http://www.w3.org/2001/XMLSchema-
instance" xmlns:wn0="http://systinet.com/xsd/SchemaTypes/"
xmlns:wn1="http://idoox.com/interface"> <e:Body> <wn0:p0 i:type="d:string">world</wn0:p0> </e:Body></e:Envelope> Parameter of type String and value world
Advanced Protocols 2004
Response Example• <?xml version="1.0" encoding="UTF-8"
standalone="yes"?> <e:Envelope
xmlns:d="http://www.w3.org/2001/XMLSchema"
xmlns:e="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i="http://www.w3.org/2001/XMLSchema-
instance" xmlns:wn0="http://systinet.com/xsd/SchemaTypes/"
xmlns:wn1="http://idoox.com/interface"> <e:Body> <wn0:string_Response i:type="d:string">Hello,
world!</wn0:string_Response> </e:Body></e:Envelope>
Returned ValueType of Value
Advanced Protocols 2004
Example of Error RPC Response
• <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<e:Envelope xmlns:d="http://www.w3.org/2001/XMLSchema"
xmlns:e="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:wn0="http://systinet.com/xsd/SchemaTypes/"
xmlns:wn1="http://idoox.com/interface">
<e:Body> <e:fault> <wn0:fault_code>e:Server</wn0:fault_code> <wn0:string_Fault i:type="d:string">Service is not Exist</wn0:string_Fault> </e:fault> </e:Body></e:Envelope>
Version Mismatch/Client/Server/MustUnderstood
Advanced Protocols 2004
Http and SOAP RPC Request
• A SOAP message can be used to transport a SOAP remote procedure request /response as follows:
POST /demo/basic/HelloService HTTP/1.0User-Agent: Systinet WASP Server for Java/5.0 (Java/1.5.0;
Windows XP/5.1)Host: 130.226.31.142:6060Connection: closeProxy-Connection: closeSOAPAction: ”Url/examples”<blankline><text for SOAP message>
Advanced Protocols 2004
An Http Request carries a SOAP RPC request
POST /demo/basic/HelloService HTTP/1.0User-Agent: Systinet WASP Server for Java/5.0 (Java/1.5.0; Windows
XP/5.1)Host: 130.226.31.142:6060Connection: closeProxy-Connection: closeSOAPAction:"http://systinet.com/wsdl/demo/basic/hello/server/
HelloService#hello?KExqYXZhL2xhbmcvU3RyaW5nOylMamF2YS9sYW5nL1N0cmluZzs="
Content-type: text/xml;charset=UTF-8X-WASP-Message-ID: 11e-FLxtbx/tDgWbei5OeHEwbw==Content-length: 356<?xml version="1.0" encoding="UTF-8"?><e:Envelope xmlns:e="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:wn0="http://systinet.com/xsd/SchemaTypes/" xmlns:wn1="http://idoox.com/interface"><e:Body><wn0:p0 i:type="d:string">world</wn0:p0></e:Body></e:Envelope>
SOAP
Action
Length of text
Advanced Protocols 2004
An Http Request that carries a SOAP Response
HTTP/1.0 200 OKDate: Sun, 21 Nov 2004 14:55:57 GMTConnection: closeServer: Systinet WASP Server for Java/5.0 (Java/1.5.0; Windows
XP/5.1)SOAPAction: ""Content-type: text/xml;charset=UTF-8X-WASP-Message-ID: 11e-FLxtbx/tDgWbei5OeHEwbw==
<?xml version="1.0" encoding="UTF-8"?><e:Envelope
xmlns:e="http://schemas.xmlsoap.org/soap/envelope/" xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:wn0="http://systinet.com/xsd/SchemaTypes/" xmlns:wn1="http://idoox.com/interface"><e:Body><wn0:string_Response i:type="d:string">Hello, world!</wn0:string_Response></e:Body></e:Envelope>
SOAP Resp
Returned Value
Advanced Protocols 2004
Error Example HTTP/1.0 500 Server ErrorDate: Sun, 21 Nov 2004 14:55:57 GMTConnection: closeServer: Systinet WASP Server for Java/5.0 (Java/1.5.0; Windows XP/5.1)SOAPAction: ""Content-type: text/xml;charset=UTF-8X-WASP-Message-ID: 11e-FLxtbx/tDgWbei5OeHEwbw==<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <e:Envelope xmlns:d="http://www.w3.org/2001/XMLSchema" xmlns:e="http://schemas.xmlsoap.org/soap/envelope/" xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns:wn0="http://systinet.com/xsd/SchemaTypes/"
xmlns:wn1="http://idoox.com/interface"><e:Body><e:fault> <wn0:fault_code>e:Server</wn0:fault_code> <wn0:string_Fault i:type="d:string">Service is not Exist</wn0:string_Fault></e:fault> </e:Body></e:Envelope>
Advanced Protocols 2004
SOAP Header Element• <?xml version="1.0"?> <soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"><soap:Header>
<m:Trans xmlns:m="http://www.w3schools.com/transaction/" soap:mustUnderstand="1">234
</m:Trans> </soap:Header>... ...</soap:Envelope> Two Attributes : Actor
Must Understand
Advanced Protocols 2004
Example on SOAP Header Element
• <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope" soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding"><soap:Header>
<m:Trans xmlns:m=http://www.w3schools.com/transaction/
soap:actor=http://www.w3schools.com/appml/
soap:mustUnderstand="1"> > 234 </m:Trans>
</soap:Header> ... ...</soap:Envelope>
URI After transaction
True/False
Advanced Protocols 2004
SOAP PackagesSource : www.soapuser.com
• Apache SOAP for Java(req lib are Xerces)• Apache Axis for Java• Systinet WASP for C++• Microsoft Toolkit (part of .net Frame
Work)• SOAP::Lite for Perl• Lucin SOAP toolset for Windows• IBM Alphaworks WSDL ToolKit• Simon Fell’s PocketSOAP
Advanced Protocols 2004
Apache SOAP
• Allow clients and server written in Java
• Part of Apache-XML project(http://xml.apache.org/#soap)
• SOAP Package downloadablehttp://xml.apache.org/dist/soap/
• Installation Instruction :http://www.xmethods.com/gettingstarted/
apache.html
Advanced Protocols 2004
Apache Soap Installation
c:
SOAP %tomcat home%
Soap 1.1
lib
Xerces.jar Mail.jar Soap.jaractivation.jar
Webapps
Jsp
web-inf
classes
Advanced Protocols 2004
Classpath Setting
• Set classpath= %classpath%;%HomeDir%\soap\soap1.1\xerces.jar;%HomeDir%\soap\soap1.1\soap.jar;
%catalina_home%\lib\servlet.jar;.;
Advanced Protocols 2004
Writing a client Application using Apache Soap
Classpath Your CLASSPATH environment variable should have both the "soap.jar" and "xerces.jar" JAR files included. Importing packages For basic SOAP method invocation, you should import the following at minimum:
// 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.*;
Advanced Protocols 2004
SOAP Datatypes• SOAP Datatypes
http://www.sdc.iup.edu/outreach/spring2002/webservices/datatypes.html
• Uses XML Schema datatypes• Primitive types
string, boolean, decimal, float, double, duration, dateTime, time, date, gYearMonth, gYear, gMonthDay, gDay, gMonth, hexBinary, base64Binary, anyURI, QName, NOTATION
• Derived typesSimple 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}
Advanced Protocols 2004
Complex Types• 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>
Advanced Protocols 2004
Summary
• SOAP is a protocol that makes use of HTTP requests and responses to effect remote method calls to webservices
• A SOAP method call is encoded in XML and is embedded in an HTTP request
• A number of SOAP APIs are available for programming web services but apache was first introduced.
Advanced Protocols 2004
References • Standard Documents
– http://www.w3.org/TR/soap/– http://www.w3.org/2002/ws/– http://www.w3.org/TR/2002/CR-soap12-part0-20021219/ (This material defines entire SOAP Primer)
• Articles – Data Types
http://www.sdc.iup.edu/outreach/spring2002/webservices/datatypes.html
– http://www.soapuser.com/resources.html– http://www.topxml.com/soap/– www.soaprpc.com