1 / 51

Web Services The “langua franca” of distributed systems?

Web Services The “langua franca” of distributed systems?. Developed by Larry LeFever for CS616: Software Engineering Seminar Spring 2003, Pace University, White Plains, NY. A Definition of a “Web Service”.

bijan
Download Presentation

Web Services The “langua franca” of distributed systems?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Web Services The “langua franca” of distributed systems? Developed by Larry LeFever for CS616: Software Engineering Seminar Spring 2003, Pace University, White Plains, NY

  2. A Definition of a “Web Service” A functionality-set or module of computational utility accessible via a network, whether LAN or WAN (e.g., the Internet) by use of textual open standard protocols such as ASCII (actually, UTF-8), XML (especially SOAP) and HTTP, especially in the interest of facilitating interoperation of nodes of an heterogeneous distributed system.

  3. Typical “Web Services” Technology-Stack: UDDI WSDL SOAP XML UTF-8 HTTP TCP/IP Ethernet/PPP/Wireless

  4. A Kind of Object-Oriented Remote Procedure Call (a.k.a. RPC) Architecture With an Open standards based Textual interface Supporting Dynamic service-discovery

  5. Können Siedas lesen?

  6. Können Sie det lesen?

  7. The Problem Just as “no man is an island”, no enterprise is an island either – not anymore. In the “good old days”, when IBM was, as it were, Microsoft, the enterprise was, indeed, an island: it invested in one massive comprehensive solution from the same vendor – named IBM, for instance. There was no Internet yet, and no need, or at least no means yet, for automated communication between different enterprises – i.e., between different systems. UPSHOT: previously, isolated homogeneous systems

  8. Enterprise-islands Not So Acquisitive, Inc. Take-Over Target, Inc. Acquisitive, Inc.

  9. Enterprise-islands Not So Acquisitive, Inc. Wishful Thinking, Inc. Monopolists ‘R’ Us Almost All of It, Inc.

  10. Enterprise-islands Not So Acquisitive, Inc. Wishful Thinking, Inc. Monopolists ‘R’ Us Almost All of It, Inc. <= “Können Sie det lesen?” =>

  11. Character-Encodings Cp500 -- IBM proprietary (EBCDIC, “Extended Binary Coded Decimal Interchange Code”): D2 CC 95 95 85 95 40 E2 89 85 40 84 85 A3 40 93 85 A2 85 95 65 4B F6 6E 6E 65 6E 20 53 69 65 20 64 65 74 20 6C 65 73 65 6E 3F ISO-8859-1 -- ANSI (public) standard (LATIN1, an “Extended ASCII”, 8-bit ASCII): Character codes from: http://std.dkuug.dk/i18n/charmaps/

  12. Character-Encodings Cp500 -- IBM proprietary (EBCDIC, “Extended Binary Coded Decimal Interchange Code”): D2 CC 95 95 85 95 40 E2 89 85 40 84 85 A3 40 93 85 A2 85 95 65 K ö n n e n S i e d e t l e s e n ? 4B F6 6E 6E 65 6E 20 53 69 65 20 64 65 74 20 6C 65 73 65 6E 3F ISO-8859-1 -- ANSI (public) standard (LATIN1, an “Extended ASCII”, 8-bit ASCII): Character codes from: http://std.dkuug.dk/i18n/charmaps/

  13. Character-Encodings Cp500 -- IBM proprietary (EBCDIC, “Extended Binary Coded Decimal Interchange Code”): D2 CC 95 95 85 95 40 E2 89 85 40 84 85 A3 40 93 85 A2 85 95 65 K ö n n e n S i e d e t l e s e n ? 4B F6 6E 6E 65 6E 20 53 69 65 20 64 65 74 20 6C 65 73 65 6E 3F ISO-8859-1 -- ANSI (public) standard (LATIN1, an “Extended ASCII”, 8-bit ASCII): Character codes from: http://std.dkuug.dk/i18n/charmaps/

  14. Character-Encodings Cp500 -- IBM proprietary (EBCDIC, “Extended Binary Coded Decimal Interchange Code”): D2 CC 95 95 85 95 40 E2 89 85 40 84 85 A3 40 93 85 A2 85 95 65 K ö n n e n S i e d e t l e s e n ? 4B F6 6E 6E 65 6E 20 53 69 65 20 64 65 74 20 6C 65 73 65 6E 3F ISO-8859-1 -- ANSI (public) standard (LATIN1, an “Extended ASCII”, 8-bit ASCII): Character codes from: http://std.dkuug.dk/i18n/charmaps/

  15. Character-Encodings Cp500 -- IBM proprietary (EBCDIC, “Extended Binary Coded Decimal Interchange Code”): D2 CC 95 95 85 95 40 E2 89 85 40 84 85 A3 40 93 85 A2 85 95 65 K ö n n e n S i e d e t l e s e n ? 4B F6 6E 6E 65 6E 20 53 69 65 20 64 65 74 20 6C 65 73 65 6E 3F ISO-8859-1 -- ANSI (public) standard (LATIN1, an “Extended ASCII”, 8-bit ASCII): Character codes from: http://std.dkuug.dk/i18n/charmaps/

  16. We need a common language. Nicht wahr? Or, rather, computers need a common character-encoding for dealing with different natural languages -- and, for that matter, even for one given language, such as English.

  17. Proprietary variants of EBCDIC, roughly one per character-set (i.e., alphabet). 8-bit encoding Proprietary variants of ASCII, roughly one per character-set (i.e., alphabet). 8-bit encoding UNICODE 16-bit encoding UTF-8 -- 8-bit, if it fits, else 16-bit or more (“UCS Transformation Format”) (UCS: Universal Character Set)

  18. ISO/IEC 10646-1 defines a multi-octet character set called the Universal Character Set (UCS) which encompasses most of the world's writing systems. Multi-octet characters, however, are not compatible with many current applications and protocols, and this has led to the development of a few so-called UCS transformation formats (UTF), each with different characteristics. UTF-8, …, has the characteristic of preserving the full US-ASCII range, providing compatibility with file systems, parsers and other software that rely on US-ASCII values but are transparent to other values… It is noteworthy that the same set of characters is defined by the Unicode standard [UNICODE] (http://www.ietf.org/rfc/rfc2279.txt; Abstract & Intro.)

  19. Character-encodings may be thought of as part of a system’s: ABI (application binary interface) … along with its: - endianness - address-alignment

  20. From: http://www.netrino.com/Publications/Glossary/Endianness.html #if defined(BIG_ENDIAN) && !defined(LITTLE_ENDIAN) #define htons(A) (A) #define htonl(A) (A) #define ntohs(A) (A) #define ntohl(A) (A) #elif defined(LITTLE_ENDIAN) && !defined(BIG_ENDIAN) #define htons(A) ((((uint16)(A) & 0xff00) >> 8) | \ (((uint16)(A) & 0x00ff) << 8)) #define htonl(A) ((((uint32)(A) & 0xff000000) >> 24) | \ (((uint32)(A) & 0x00ff0000) >> 8) | \ (((uint32)(A) & 0x0000ff00) << 8) | \ (((uint32)(A) & 0x000000ff) << 24)) #define ntohs htons #define ntohl htohl

  21. From: http://ciips.ee.uwa.edu.au/~morris/Year1/CLP110/struct.html struct padded { char a; double e; /* might start on 8-byte boundary! */ int x, y; struct f g; }; printf("%d\n", sizeof( struct padded ) );

  22. From: http://ciips.ee.uwa.edu.au/~morris/Year1/CLP110/struct.html

  23. From: http://ciips.ee.uwa.edu.au/~morris/Year1/CLP110/struct.html “By printing out sizeof (struct t_labelled_point -- see following, ed. LL), you discovered that your machine pads the structure to 16 bytes. By examining the binary file, you've confirmed that there are 7 null bytes after each character. However, the same exercise on the target machine shows that the struct isn't padded, i.e., it only takes 9 bytes, so we need to do some hacking to read the file.”

  24. #include "labelled_point.h" #define BUF_LEN 16 #define Z_OFFSET 8/* <== EMPHASIS ADDED !!! */ int load_point_array( labelled_point a[], int n ) { /* a is an array of objects constructed by calls to the appropriate constructor */ int f, i, nb; char buf[BUF_LEN]; f = open( "dump.dat", 0 ); for(i=0;i<n;i++) { /* Read data into a character buffer */ nb = read( f, buf, BUF_LEN ); a[i]->a = buf[0]; /* First char is the label */ memcpy( &(a[i]->z), &buf[Z_OFFSET], sizeof(double) ); /* <== EMPHASIS ADDED !!! */ } .. return .. }

  25. One might say that what we need is an: ATI (application textual interface*) *a term of my own devising

  26. Enter: XML (extensible mark-up language) A “meta-mark-up language”, A mark-up language for defining Other markup languages

  27. From: http://javaboutique.internet.com/tutorials/SOAP/index.html POST /StockQuote HTTP/1.1 Host: www.stockquoteserver.com Content-Type: text/xml; charset="utf-8” Content-Length: nnnn SOAPAction:"Some-URI" <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <SOAP-ENV:Body> <m:GetLastTradePrice xmlns:m="Some-URI"> <symbol>DIS</symbol> </m:GetLastTradePrice> </SOAP-ENV:Body > </SOAP-ENV:Envelope> <==== simple datatype, as opposed to composite type, like C-struct

  28. From: http://javaboutique.internet.com/tutorials/SOAP/index.html HTTP/1.1 200 OK Content-Type: text/xml; charset="utf-8” Content-Length: nnnn <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/ > <SOAP-ENV:Body> <m:GetLastTradePriceResponse xmlns:m="Some-URI"> <Price>34.5</Price> </m:GetLastTradePriceResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope>

  29. Parameter-Marshalling - DCE-RPC, X/Open-RPC, MS-DCOM, CORBA, Sun-RMI - binary - Web Services - textual (XML => SOAP)

  30. http://www.opengroup.org/onlinepubs/009629399/chap12.htm#tagcjh_17_02http://www.opengroup.org/onlinepubs/009629399/chap12.htm#tagcjh_17_02 DCE Network Data Representation (NDR) (similar to X/Open’s External Data Representation (XDR)) typedef struct { p_context_id_t p_cont_id; u_int8 n_transfer_syn; /* number of items */ u_int8 reserved; /* alignment pad, m.b.z. */ p_syntax_id_t abstract_syntax; /* transfer syntax list */ p_syntax_id_t [size_is(n_transfer_syn)] transfer_syntaxes[]; } p_cont_elem_t; typedef struct { u_int8 n_context_elem; /* number of items */ u_int8 reserved; /* alignment pad, m.b.z. */ u_short reserved2; /* alignment pad, m.b.z. */ p_cont_elem_t [size_is(n_cont_elem)] p_cont_elem[]; } p_cont_list_t;

  31. http://javaboutique.internet.com/tutorials/SOAP/index2.html class Person { String name; int age; } class Aservice { public String acceptPerson(Person p) { //do something here return “a string”; } } ||||||||||||||||||||||||||||| XML for calling “acceptPerson” ||||||||||||||||||||||||||||||||||||||||||||| <SOAP-ENV:Body> <ns1:acceptPerson xmlns:ns1=”urn:the urn of the service” SOAP-ENV:encodingStyle = “http://schemas.xmlsoap.org/soap/encoding/”> <serviceParam xmlns:ns2=”some uri” xsi:type=”ns2:Person”> <age xsi:type=” xsd:int”>22</age> <name xsi:type=xsd:string”>Samudra</name> </serviceParam> </ns1:acceptPerson> </SOAP-ENV:Body> <== composite datatype <== extremely simple “Web Service”

  32. http://javaboutique.internet.com/tutorials/SOAP/client2.html Apache SOAP: Example Web Service Invocation public static void main(String[] args) { String urlString = args[0]; String name = args[1]; SoapClient client = new SoapClient(urlString); Person nameObject = new Person(); nameObject.setName(name); nameObject.setAge(22); Call call = new Call(); call.setTargetObjectURI("urn:greetingService"); call.setMethodName("sayGreeting"); call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC); SOAPMappingRegistry smr = new SOAPMappingRegistry(); BeanSerializer bsr = new BeanSerializer();<== !!! QName qn = new QName("urn:greetingService", "sam.soap.client.Person"); smr.mapTypes.(Constants.NS_URI_SOAP_ENC, qn, sam.soap.client.Person.class, bsr, bsr); call.setSOAPMappingRegistry(smr); Vector v = new Vector(); Parameter param1 = new Parameter("name", sam.soap.client.Person.class, nameObject, null); v.addElement(param1); call.setParams(v);

  33. http://javaboutique.internet.com/tutorials/SOAP/client2.html Apache SOAP: Example Web Service Invocation (cont.) Response res = call.invoke(new URL(client.urlString), ""); if( res.generatedFault() ==false) { Parameter retValue = res.getReturnValue(); Object value = retValue.getValue(); System.out.println(value); } else { System.out.println("The fault is: "+res.getFault().getFaultString()); }

  34. http://javaboutique.internet.com/tutorials/SOAP/index3.html Apache SOAP: Custom Serialization public class PersonSerializer extends Object implements Serializer, Deserializer { public void marshall(String inScopeEncStyle, Class javaType, Object src, Object context, Writer sink, NSStack nsStack, XMLJavaMappingRegistry xjmr, SOAPContext ctx) throws IllegalArgumentException,IOException { inScopeEncStyle: This represents the encodingStyleURI as specified in the enclosing Call or Response object. javaType: This is the run-time type of the object that is to be serialized. src: This is a reference to the ***Java object *** to be serialized. context: A String denoting the accessor name It must be non-null. sink: The destination to which the *** SOAP XML instance *** will be written. nsStack: A data structure that implements a stack of namespace declarations that are currently in scope. xjmr: This is the XMLJavaMappingRegistry object. ctx: This is used to pass in things like javax.servlet.http.HttpServletRequest and javax.servlet.http.HttpSession from the servlet context.

  35. http://javaboutique.internet.com/tutorials/SOAP/index3.html Apache SOAP: Custom Serialization (cont.) SoapEncUtils.generateStructureHeader(inScopeEncStyle, javaType, context, sink, nsStack, xjmr); sink.write(StringUtils.lineSeparator); Person person = (Person)src; String name = person.getName(); int age = person.getAge(); if(name !=null) { xjmr.marshall(inScopeEncStyle, String.class, name, "name", sink, nsStack, ctx); //fill the gap for the age parameter yourself…… sink.write(StringUtils.lineSeparator); } sink.write("</" + context + '>'); |||||||||||||||||||||||||||||| The Generated XML-instance ||||||||||||||||||||||||||||||||||||||||||||||||||| <serviceParam xmlns:ns2=”some uri” xsi:type=”ns2:Person”> <age xsi:type=” xsd:int”>22</age> <name xsi:type=xsd:string”>Paul</name> </serviceParam>

  36. Apache SOAP: Default Serialization public class BeanSerializer implements Serializer, Deserializer { public void marshall(String inScopeEncStyle, Class javaType, Object src, Object context, Writer sink, NSStack nsStack, XMLJavaMappingRegistry xjmr, SOAPContext ctx) throws IllegalArgumentException, IOException { … PropertyDescriptor[] properties = getPropertyDescriptors(javaType); for (int i = 0; i < properties.length; i++) { String propName = properties[i].getName(); Class propType = properties[i].getPropertyType(); // Serialize every property except the "class" property. if (!propType.equals(Class.class)){ Method propReadMethod = properties[i].getReadMethod(); // Only serialize readable properties. if (propReadMethod != null){ Object propValue = null; // Get the property's value. try{ if (src != null) { propValue = propReadMethod.invoke(src, new Object[]{}); } } catch (Exception e) {…} // Serialize the property. Parameter param = new Parameter(propName, propType, propValue, null); xjmr.marshall(Constants.NS_URI_SOAP_ENC, Parameter.class, param, null, sink, nsStack, ctx);

  37. Apache SOAP: Default Serialization (cont.) private PropertyDescriptor[] getPropertyDescriptors(Class javaType) throws IllegalArgumentException { BeanInfo beanInfo = null; try { beanInfo = Introspector.getBeanInfo(javaType); } … From: \soap-src-2.3\soap-2_3\src\org\apache\soap\encoding\soapenc\BeanSerializer.java

  38. Web Services Description Language (WSDL): WSDL is an XML format for describing network services as a set of endpoints operating on messages containing either document-oriented or procedure-oriented information. The operations and messages are described abstractly, and then bound to a concrete network protocol and message format to define an endpoint (from: http://www.w3.org/TR/wsdl#_soap-e) Universal Description, Discovery & Integration (UDDI): The UDDI Business Registry is the implementation of the specification developed by uddi.org. The UDDI Business Registry is a core element of the infrastructure that supports web services. The UDDI Business Registry provides a place for a company to register its business and the services that it offers. People or businesses that need a service can use this registry to find a business that provides the service. (from: http://www.uddi.org/faqs.html#who)

  39. WSDL Example(from: http://www.w3.org/TR/wsdl#_soap-e) <?xml version="1.0"?> <definitions name="StockQuote" targetNamespace="http://example.com/stockquote.wsdl" xmlns:tns="http://example.com/stockquote.wsdl" xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" xmlns:xsd1="http://example.com/stockquote.xsd" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns="http://schemas.xmlsoap.org/wsdl/"> <message name="GetTradePriceInput"> <part name="tickerSymbol" element="xsd:string"/> <part name="time" element="xsd:timeInstant"/> </message> <message name="GetTradePriceOutput"> <part name="result" type="xsd:float"/> </message> <portType name="StockQuotePortType"> <operation name="GetTradePrice"> <input message="tns:GetTradePriceInput"/> <output message="tns:GetTradePriceOutput"/> </operation> </portType>

  40. WSDL Example(cont.) <binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType"> <soap:binding style="rpc"transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="GetTradePrice"> <soap:operation soapAction="http://example.com/GetTradePrice"/> <input> <soap:body use="encoded" namespace="http://example.com/stockquote" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </input> <output> <soap:body use="encoded" namespace="http://example.com/stockquote" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/> </output> </operation>> </binding> <service name="StockQuoteService"> <documentation>My first service</documentation> <port name="StockQuotePort" binding="tns:StockQuoteBinding"> <soap:address location="http://example.com/stockquote"/> </port> </service> </definitions>

  41. Q: How does UDDI relate to WSDL? A: There is no formal relationship between UDDI and WSDL (Web Services Description Language), although the technologies are complementary. WSDL can be used to specify a web service interface. The tModel (see following, ed. LL) entry for the service type could point to a WSDL abstract description, and the binding template for a specific service could point to a WSDL concrete description. (from: http://www.uddi.org/faqs.html#web)

  42. From: http://www.oasis-open.org/committees/uddi-spec/doc/bp/uddi-spec-tc-bp-using-wsdl-v108-20021110.htm The “tModel” (“t” for Taxonomy): <tModel authorizedName="..." operator="..." tModelKey="..."> <name>StockQuote Service</name> <description xml:lang="en"> WSDL description of a standard stock quote service interface </description> <overviewDoc> <description xml:lang="en"> WSDL source document. </description> <overviewURL> http://example.com/stockquote.wsdl </overviewURL> </overviewDoc> <categoryBag> <keyedReference tModelKey=" uuid:C1ACF26D-9672-4404-9D70-39B756E62AB4" keyName="uddi-org:types" keyValue="wsdlSpec"/> </categoryBag> </tModel>

  43. From: http://www.oasis-open.org/committees/uddi-spec/doc/bp/uddi-spec-tc-bp-using-wsdl-v108-20021110.htm The “Binding Template”: <businessService businessKey="..." serviceKey="..."> <name>StockQuoteService</name> <description> (...) </description> <bindingTemplates> <bindingTemplate> (...) <accessPoint urlType="http"> http://example.com/stockquote </accessPoint> <tModelnstanceDetails> <tModelnstanceInfo tModelKey="..."> </tModelnstanceInfo> <tModelnstanceDetails> </bindingTemplate> </bindingTemplates> </businessService>

  44. What is Axis? Axis is essentially a SOAP engine -- a framework for constructing SOAP processors such as clients, servers, gateways, etc. The current version of Axis is written in Java .... …Axis isn't just a SOAP engine -- it also includes: a simple stand-alone server, a server which plugs into servlet engines such as Tomcat, extensive support for the Web Service Description Language (WSDL), emitter tooling that generates Java classes from WSDL. some sample programs, and a tool for monitoring TCP/IP packets. (from: http://ws.apache.org/axis/ -- Axis User’s Guide)

  45. Axis provides a utility to generate the skeletons from the WSDL.. An example invocation follows: java org.apache.axis.wsdl.WSDL2Java --server-side --skeletonDeploy true MessageObject.wsdl Axis provides a utility to generate the stubs from the WSDL.. An example invocation follows: java org.apache.axis.wsdl.WSDL2Java MessageObject.wsdl From: http://www.cs.unc.edu/Courses/comp190/docs/lessons/ws/ws_wsdl/

  46. Security:(from: http://216.239.57.100/search?q=cache:GyWSEczHfFQC: www.oasis-open.org/presentations/security/PMishra.ppt+SAML+basic+example&hl=en&ie=UTF-8) - various standards being developed - for example, Security Assertions Markup Language (SAML) <saml:assertion Issuer=“example.com”…> <saml:Conditions NotBefore=… NotAfter=…/> <saml:AuthenticationStatement AuthenticationMethod=… AuthenticationInstant=… > <saml:subject …>John Doe</saml:subject> </saml:AuthenticationStatement> <saml:AttributeStatement> <saml:subject …>John Doe</saml:subject> <saml:Attribute AttributeName=“Title” …> <saml:AttributeValue>Manager</AttributeValue> </saml:Attribute> <saml:Attribute AttributeName=“SpendLimit” …> <saml:AttributeValue>10,000</AttributeValue> </saml:Attribute> </saml:AttributeStatement> </saml:Assertion>

  47. WS-I (Web Services Interoperability Organization): WS-I was formed specifically for the creation, promotion, or support of Generic Protocols for Interoperable exchange of messages between services. Generic Protocols are protocols that are independent of any specific action indicated by the message beyond actions necessary for the secure, reliable, or efficient delivery of messages; "Interoperable" means suitable for and capable of being implemented in a neutral manner on multiple operating systems and in multiple programming languages. (from: http://www.ws-i.org/)

  48. What the WS-I does: • Web Services testing and implementation guidance to accelerate customer deployments • Encourage best-practices use of "baseline" Web Services today (XML, SOAP, WSDL, UDDI) • Deliver a set of self-administered test suites for conformance of baseline specification implementations aimed at improving interoperation of infrastructure and applications. (from: http://www.ws-i.org/FAQ.aspx#A01)

  49. A Definition of a “Web Service” A functionality-set or module of computational utility accessible via a network, whether LAN or WAN (e.g., the Internet) by use of textual open standard protocols such as ASCII (actually, UTF-8), XML (especially SOAP) and HTTP, especially in the interest of facilitating interoperation of nodes of an heterogeneous distributed system.

  50. Typical “Web Services” Technology-Stack: UDDI WSDL SOAP XML UTF-8 HTTP TCP/IP Ethernet/PPP/Wireless

More Related