400 likes | 562 Vues
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
E N D
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
Presentation Overview 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 • 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 Service Provider Service Provider ”Server” Publish(WSDL) Bind(SOAP) Service Broker Service Broker Service Requestor Service Requestor Find(UDDI) • 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” ”Server” • SOAP & WSDL- W3 Standards • UDDI – OASIS Standard Advanced Protocols 2004 ”Naming Service” ”client”
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. Advanced Protocols 2004
WebService Protocol Stack &Protocols 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 Webservice Repository (UDDI) (manual)web Service Lookup 2 http Get 3 WSDL file 1 Register WSDLfile(manually) Reads Parameters Functions Web Service Provider Publish web Service 4 SOAP Req Write client Application 5 SOAP Resp Advanced Protocols 2004
Web Services Implementation Web Service Provider Requestor Http Server Soap Server Application server Soap Messages (http transport) Soap Client • 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) ~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) 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 Advanced Protocols 2004
SOAP Messages 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 Soap Message Object with No Attachments Advanced Protocols 2004
An XML –encoded SOAP RPC Name Space <?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> Encoding Style Advanced Protocols 2004
Example of a SOAP Message 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 Name Parameters 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 Value Type 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.0 User-Agent: Systinet WASP Server for Java/5.0 (Java/1.5.0; Windows XP/5.1) Host: 130.226.31.142:6060 Connection: close Proxy-Connection: close SOAPAction: ”Url/examples” <blankline> <text for SOAP message> Advanced Protocols 2004
An Http Request carries a SOAP RPC request POST /demo/basic/HelloService HTTP/1.0 User-Agent: Systinet WASP Server for Java/5.0 (Java/1.5.0; Windows XP/5.1) Host: 130.226.31.142:6060 Connection: close Proxy-Connection: close SOAPAction: "http://systinet.com/wsdl/demo/basic/hello/server/HelloService#hello?KExqYXZhL2xhbmcvU3RyaW5nOylMamF2YS9sYW5nL1N0cmluZzs=" Content-type: text/xml;charset=UTF-8 X-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> Action Length of text SOAP Advanced Protocols 2004
An Http Request that carries a SOAP Response HTTP/1.0 200 OK Date: Sun, 21 Nov 2004 14:55:57 GMT Connection: close Server: Systinet WASP Server for Java/5.0 (Java/1.5.0; Windows XP/5.1) SOAPAction: "" Content-type: text/xml;charset=UTF-8 X-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 Error Date: Sun, 21 Nov 2004 14:55:57 GMT Connection: close Server: Systinet WASP Server for Java/5.0 (Java/1.5.0; Windows XP/5.1) SOAPAction: "" Content-type: text/xml;charset=UTF-8 X-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 Message with Attachements SOAP Message with Attachments 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 downloadable http://xml.apache.org/dist/soap/ • Installation Instruction : http://www.xmethods.com/gettingstarted/apache.html Advanced Protocols 2004
Apache Soap Installation c: %tomcat home% SOAP Soap 1.1 Webapps Jsp web-inf lib activation.jar Xerces.jar Mail.jar Soap.jar 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 ClasspathYour CLASSPATH environment variable should have both the "soap.jar" and "xerces.jar" JAR files included. Importing packagesFor 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 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} 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
Implementation of Systinet 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 Advanced Protocols 2004