CSE 190 Internet ECommerce Lecture 19 SOAP WAP

  • Slides: 20
Download presentation
CSE 190: Internet E-Commerce Lecture 19: SOAP, WAP

CSE 190: Internet E-Commerce Lecture 19: SOAP, WAP

Machines that talk • We have web services for people • How do we

Machines that talk • We have web services for people • How do we enable machines that interoperate? – XML as a way of representing data – But need a mechanism for communicating remote procedure calls. • Example: – Travel site providing driving directions to your hotel

Motivations • Heterogeneous systems must be able to communicate • Binary protocols don’t always

Motivations • Heterogeneous systems must be able to communicate • Binary protocols don’t always work – CORBA, DCOM, etc. don’t work well through firewalls – Nobody can agree on a standard binary format (usually due to platform-related issues) – We’re dealing with many heterogeneous environments (MVS, Unix, Windows NT, Linux, Palm. OS, etc. ) – Component runtimes differ – Security models differ (Kerberos, NTLM, OSF-DCE)

What we need. . . • • • Standards (as usual) A firewall-friendly protocol

What we need. . . • • • Standards (as usual) A firewall-friendly protocol An extensible framework Low cost of entry Loose coupling Platform and programming language agnostic technology

SOAP • SOAP: a method for doing RPC using XML to encode the parameters

SOAP • SOAP: a method for doing RPC using XML to encode the parameters to our functions – For application to application integration • SOAP: Simple Object Access Protocol • Why not DCOM, CORBA, JNI? – Don’t natively work over HTTP, need custom ports – Even when they do, not human-readable • SOAP pitfall – Argument marshaling less efficient • A W 3 C Standard

SOAP Example: Request <soap: Envelope> <soap: Body> <xmlns: m= "http: //www. amzn. org/books" />

SOAP Example: Request <soap: Envelope> <soap: Body> <xmlns: m= "http: //www. amzn. org/books" /> <m: Get. Book. Price> <m: Book. Name>Fast Food Nation</m: Book. Name> </m: Get. Book. Price> </soap: Body> </soap: Envelope>

SOAP Example: Response <soap: Envelope> <soap: Body> <xmlns: m="http: //www. amzn. org/books" /> <m:

SOAP Example: Response <soap: Envelope> <soap: Body> <xmlns: m="http: //www. amzn. org/books" /> <m: Get. Book. Price. Response> <m: Price>34. 5</m: Price> </m: Get. Book. Price. Response> </soap: Body> </soap: Envelope>

SOAP Example: Error <soap: Fault> <faultcode>0 x 800700 E</faultcode> <faulstring>Unknown book</faultstring> </soap: Fault>

SOAP Example: Error <soap: Fault> <faultcode>0 x 800700 E</faultcode> <faulstring>Unknown book</faultstring> </soap: Fault>

SOAP Structure • Envelope contains – Header – Body • Header is optional –

SOAP Structure • Envelope contains – Header – Body • Header is optional – Out-of-band information such as… • • Authentication information Message routes Logging Transaction flow • Body contains XML body of RPC call

SOAP Example 2 <? xml version="1. 0" encoding="UTF-8" ? > <env: Envelope xmlns: env="http:

SOAP Example 2 <? xml version="1. 0" encoding="UTF-8" ? > <env: Envelope xmlns: env="http: //www. w 3. org/2001/09/soapenvelope"> <env: Header> <n: alertcontrol xmlns: n="http: //example. org/alertcontrol"> <n: priority>1</n: priority> <n: expires>2001 -06 -22 T 14: 00 -05: 00</n: expires> </n: alertcontrol> </env: Header> <env: Body> <m: alert xmlns: m="http: //example. org/alert"> <m: msg>Pick up Mary at school at 2 pm</m: msg> </m: alert> </env: Body> </env: Envelope>

Values and References • By value - Add([in] int a, [in] int b); <m:

Values and References • By value - Add([in] int a, [in] int b); <m: Add xmlns: m=“http: //a. com/Calculator”> <a xsi: type=“integer”>3</a> <b xsi: type=“integer”>4</b> </m: Add> • By reference - Square([in, out] int &a); <m: Add xmlns: m=“http: //a. com/Calculator”> <a href=“#arg” /> </m: Add> <a id=“arg” xsi: type=“integer”>8</a>

Arrays • Arrays int a[3] = {1, 2, 3}; b = Add([in]a); <m: Add

Arrays • Arrays int a[3] = {1, 2, 3}; b = Add([in]a); <m: Add xmlns: m=“http: //a. com/Calculator” xmlns: SOAP-ENC="http: //schemas. xmlsoap. org/soap/encoding/”> <a SOAP-ENC: array. Type=“xsd: int[3]”> <SOAP-ENC: int>1</SOAP-ENC: int> <SOAP-ENC: int>2</SOAP-ENC: int> <SOAP-ENC: int>3</SOAP-ENC: int> </a> </m: Add>

SOAP over HTTP (Request) POST /Calculator. pl HTTP/1. 0 Host: www. a. com Accept:

SOAP over HTTP (Request) POST /Calculator. pl HTTP/1. 0 Host: www. a. com Accept: text/* Content-type: text/xml Content-length: nnnn SOAPAction: “http: //www. a. com/Calculator#Add” {CR}{LF} <SOAP-ENV: Envelope xmlns: SOAP-ENV=“http: //schemas. xmlsoap. org/soap/envelope/” SOAP-ENV: encoding. Style="http: //schemas. xmlsoap. org/soap/encoding/”> <SOAP-ENV: Header> <t: trans. Id xmlns: t=“http: //a. com/trans”>1234</t: trans. Id> </SOAP-ENV: Header> <SOAP-ENV: Body> <m: Add xmlns: m=“http: //a. com/Calculator”> <a xsi: type=“integer”>3</a> <b xsi: type=“integer”>4</b> </m: Add> </SOAP-ENV: Body> </SOAP-ENV: Envelope>

SOAP over HTTP (Response) HTTP/1. 0 200 OK Content-type: text/xml Content-length: nnnn {CR}{LF} <SOAP-ENV:

SOAP over HTTP (Response) HTTP/1. 0 200 OK Content-type: text/xml Content-length: nnnn {CR}{LF} <SOAP-ENV: Envelope xmlns: SOAP-ENV=“http: //schemas. xmlsoap. org/soap/envelope/” SOAP-ENV: encoding. Style="http: //schemas. xmlsoap. org/soap/encoding/”> <SOAP-ENV: Header> <t: trans. Id xmlns: t=“http: //a. com/trans”>1234</t: trans. Id> </SOAP-ENV: Header> <SOAP-ENV: Body> <m: Add. Response xmlns: m=“http: //a. com/Calculator”> <c xsi: type=“integer”>7</c> </m: Add. Response> </SOAP-ENV: Body> </SOAP-ENV: Envelope>

WSDL(Web Services Description Language) Describing available SOAP Service (First, data types passed to web

WSDL(Web Services Description Language) Describing available SOAP Service (First, data types passed to web services) http: //example. com/stockquote. xsd <? xml version="1. 0"? > <schema target. Namespace="http: //example. com/stockquote/schemas" xmlns="http: //www. w 3. org/2000/10/XMLSchema"> <element name="Trade. Price. Request"> <complex. Type> <all> <element name="ticker. Symbol" type="string"/> </all> </complex. Type> </element> <element name="Trade. Price"> <complex. Type> <all> <element name="price" type="float"/> </all> </complex. Type> </element> </schema>

WSDL (cot’d) (Then, the actual methods and expected response structure) http: //example. com/stockquote. wsdl

WSDL (cot’d) (Then, the actual methods and expected response structure) http: //example. com/stockquote. wsdl <? xml version="1. 0"? > <definitions name="Stock. Quote" target. Namespace="http: //example. com/stockquote/definitions" xmlns: tns="http: //example. com/stockquote/definitions" xmlns: xsd 1="http: //example. com/stockquote/schemas" xmlns: soap="http: //schemas. xmlsoap. org/wsdl/soap/" xmlns="http: //schemas. xmlsoap. org/wsdl/"> <import namespace="http: //example. com/stockquote/schemas" location="http: //example. com/stockquote. xsd"/> <message name="Get. Last. Trade. Price. Input"> <part name="body" element="xsd 1: Trade. Price. Request"/> </message> <message name="Get. Last. Trade. Price. Output"> <part name="body" element="xsd 1: Trade. Price"/> </message> <port. Type name="Stock. Quote. Port. Type"> <operation name="Get. Last. Trade. Price"> <input message="tns: Get. Last. Trade. Price. Input"/> <output message="tns: Get. Last. Trade. Price. Output"/> </operation> </port. Type> </definitions>

SOAP + WSDL: Half of what. NET is about • . NET: Building web

SOAP + WSDL: Half of what. NET is about • . NET: Building web services as components that may be re-used in other applications • Hasn’t happened yet

. NET (cot’d) • Second half of. NET: A set of language tools for

. NET (cot’d) • Second half of. NET: A set of language tools for developing web services and Win 32 languages – New languages: C#, VB. NET • What’s new: Common Language Runtime – Allows multiple languages to use the same runtime libraries – Development tools: ASP. NET, ADO. NET • ASP. NET: Ignore the HTTP request/response structure and statelessness issues – Structure web sites as if you were assembling form code • ADO. NET: Disconnected record-sets (in memory DB)

WAP, WML • WAP: Wireless Application Protocol • WML: Wireless Markup Language – Allows

WAP, WML • WAP: Wireless Application Protocol • WML: Wireless Markup Language – Allows simple pages to be viewed by your mobile phone browser – Through a proxy, pages returned via normal HTTP – WML is not HTML • Standardized by the WAP forum

WML Example • WML is an XML document <? xml version="1. 0"? > <!DOCTYPE

WML Example • WML is an XML document <? xml version="1. 0"? > <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1. 1//EN" "http: //www. wapforum. org/DTD/wml_1. 1. xml"> <wml> <card id="HTML" title="HTML Tutorial"> <p> Our HTML Tutorial is an award winning tutorial from W 3 Schools. </p> </card> <card id="XML" title="XML Tutorial"> <p> Our XML Tutorial is an award winning tutorial from W 3 Schools. </p> </card> </wml>