1 / 90

Co-Dependencies of Concepts

Co-Dependencies of Concepts. What Does It Mean?. What Does It Mean?. Service-Orientation Principles. Reuse Blocks of logic, mutually sought by many Statelessness Should not be required to manage the state of interactions Sessions; users “statefulness”  tight coupling Loose coupling

idalia
Download Presentation

Co-Dependencies of Concepts

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. Co-Dependencies of Concepts CIS 340

  2. What Does It Mean? CIS 340

  3. What Does It Mean? CIS 340

  4. Service-Orientation Principles • Reuse • Blocks of logic, mutually sought by many • Statelessness • Should not be required to manage the state of interactions • Sessions; users • “statefulness”  tight coupling • Loose coupling • Emergent property of statelessness; autonomy; abstraction • Autonomy • Bounded & focused; independence • Abstraction • External visibility == service description • May be composed • Small logics may be combined into larger ones • Does notimply forfeiture of loose coupling, autonomy, or abstraction • Discoverability • Registry of service descriptions

  5. What is WSDL • Web Service Description Language. • An XML language used to describe and locate web services. • Written in XML. • Describe functionality of a web service • Specify how to access the service (binding protocol, message format, and etc.) • Not a W3C standard yet. • Version 1.1 released March 2001 • Working draft of Version 1.2 released July 2003

  6. WSDL Introduction • WSDL contains information about the interfacesemantics and ‘administrivia’ of a call to a Web Service • Once you develop a Web Service you publish its description and a link to it in a UDDI repository so that potential users can find it • When someone wants to use your service, they request the WSDL file in order to find out the location of the service, the function calls and how to access them • Then they use this information in your WSDL file to form a SOAP request to the computer

  7. Why Use WSDL? • WSDL uses XML to describe interfaces • Programming language independent way to do this. • So you can use (for example) C# programs to remotely invoke java programs. • Consider Web browsers and Web servers: • All web browsers work pretty well with all web sites. • You don’t care what kind of web server Amazon.com uses. • Amazon doesn’t care if you use IE, Mozilla, Konqueror, Safari, etc. • You all speak HTTP. • WSDL (and SOAP) are a generalization of this.

  8. Working of WSDL (with Java)

  9. Working of WSDL contd. • A client can invoke a web service using SOAP, HTTP GET/POST and MIME. • WSDL Document Structure • <definition> - Root element • <types> - Provides data type definitions • <message> - Represents the abstract definition of the data being transmitted • <portType> - Defines a set of abstract operations • <binding> - Specifies concrete protocol and data format specifications for the operations and messages defined by a particular portType • <port> - Specifies an address for a binding • <service> - Used to aggregate a set of related ports.

  10. Namespace • The XML namespace prefix are used to indicate the namespace of the element being defined • All WSDL elements belong to the WSDL namespace, defined as http://schemas.xmlsoap.org/wsdl/ • For WSDL SOAP binding, http://schemas.xmlsoap.org/wsdl/soap/ • For WSDL HTTP GET and POST binding, http://schemas.xmlsoap.org/wsdl/http/ • For WSDL MIME binding, http://schemas.xmlsoap.org/wsdl/mime/

  11. Service • A service groups a set of related ports together • Let is consider an example of a Web Service and the GetTemperature method as an operation on that service. <definitions name=‘weatherservice’ xmlns=‘http://schemas.xmlsoap.org/wsdl/’> <type> <xsd:schema … /> </type> <service name=‘WeatherService’ > … </service> </definitions>

  12. Port • A port defines an individual endpoint by specifying a single address for a binding <port name=‘WeatherSoapPort’ binding=‘wsdlns:WeatherSoapBinding’ > <soap:address location=‘http://localhost/demos/wsdl/devx pert/weatherservice.asp’ /> </port> • Each port has a unique name and a binding attribute • A web service may be accessible on many ports • A port MUST NOT specify more than one address • A port MUST NOT specify any binding information other than address information

  13. Message • A message is protocol independent • There is an input or request message, which is sent from the client to the service, and there is a output or response message, which is sent back the opposite way • Each <message> element contains one or more <part> elements. • <part> element corresponds to the parameter or a return value in the RPC call. • The part name order reflects the order of the parameters in the RPC signature.

  14. Message contd. <message name=‘Weather.GetTemperature’ > <part name=‘zipcode’ type=‘xsd:string’ /> <part name=‘celsius’ type=‘xsd:boolean’ /> </message> <message name=‘Weather.GetTemperatureResponse’ > <part name=‘Result’ type=‘xsd:float’ /> </message>

  15. Operations and PortType • Operation defines which message is the input and which message is the output • A collection of all operations exposed by the web service is called a portType <portType name=‘WeatherSoapPort’> <operation name=‘GetTemperature’ parameterOrder=‘zipcode celsius’> <input message=‘wsdlns:Weather.GetTemperature’ /> <output message=‘wsdlns:Weather.GetTemperatureResponse’ /> </operation> <!– other operations  </portType>

  16. Operations and PortType • WSDL has four transmission primitives that an endpoint can support: • One-Way – The endpoint receives a message <wsdl:input> • Request-response – The endpoint receives a message and sends a correlated message <wsdl:input>,<wsdl:output>,<wsdl:fault> • Solicit-response – The endpoint sends a message and receives a correlated message <wsdl:output>, <wsdl:input>, <wsdl:fault> • Notification – The endpoint sends a message <wsdl:output>

  17. Binding • Binding mechanism is used to attach a specific protocol, data format or structure to an abstract message , operation or endpoint • Binding MUST specify exactly one protocol • Binding MUST NOT specify address information • Extensibility elements are commonly used to specify some technology specific binding <binding name=‘WeatherSoapBinding’ type=‘wsdlns:WeatherSoapPort’ > … </binding>

  18. SOAP Binding • <soap:binding> - Signifies that the binding is bound to the SOAP protocol format: Envelope, Header and Body <binding …> <soap:binding transport=“uri”? Style=“rpc|document”?> </binding> • <soap:operation> - Provides information for the document as a whole <binding …> <operation …> <soap:operation soapAction=“uri”? Style=“rpc|document”?> </operation> </binding>

  19. SOAP Binding contd. • <soap:body> - Specifies how the message parts appear inside the SOAP Body element <input> <soap:body parts=“nmtokens”? use=“literal|encoded”? encodingStyle=“uri-list”? Namespace=“uri”?> </input> • <soap:fault> - Specifies the contents of the contents of the SOAP fault <fault> <soap:fault name=“nmtoken” use=“literal|encoded” encodingStyle=“uri-list”? Namespace=“uri”?> </fault>

  20. SOAP binding contd. • <soap:header> and <soap:headerfault> - Allow headers to be defined that are transmitted inside the Header element of the SOAP Envelope <input> <soap:header message=“qname” part=“nmtoken” use=“literal|encoded”? encodingStyle=“uri-list”? Namespace=“uri”?> <soap:headerfault message=“qname” part=“nmtoken” use=“literal|encoded”? encodingStyle=“uri-list”? Namespace=“uri”?> </input> • <soap:address> - Used to give a port an address (a URI) <binding …> <soap:address location=“uri” /> </binding>

  21. The Main Structure of WSDL <definition namespace = “http/… “> <type> xschema types </type> <message> … </message> <port> a set of operations </port> <binding> communication protocols </binding> <service> a list of binding and ports </service> <definition>

  22. Types • <types> define types used in message declaration • XML Schema, DTD, and etc. • XML Schema must be supported by any vendor of WSDL conformant products.

  23. <types> <schema targetNamespace="http://example.com/stockquote.xsd" xmlns="http://www.w3.org/2000/10/XMLSchema"> <element name="TradePriceRequest"> <complexType> <all> <element name="tickerSymbol" type="string“ minOccur = “1” maxOccur=“10”/> <element name = “payment”> <complexType> <choice> <element name = “account” type=“string”> <element name = “creditcard” type=“string”> </choice> </complexType> </element> </all> </complexType> </element> </schema> </types>

  24. WSDL Messages • The <message> element defines the data elements of an operation. • Each messages can consist of one or more parts. The parts can be compared to the parameters of a function call in a traditional programming language.

  25. <message name="GetLastTradePriceInput"> <part name="body" element="TradePriceRequest"/> </message> <message name="GetLastTradePriceOutput"> <part name="body" element="TradePrice"/> </message>

  26. WSDL Ports • The <portType> element is the most important WSDL element. • It defines a web service, the operations that can be performed, and the messages that are involved. • The <port> defines the connection point to a web service, an instance of <portType>. • It can be compared to a function library (or a module, or a class) in a traditional programming language. Each operation can be compared to a function in a traditional programming language.

  27. <portType name="StockQuotePortType"> <operation name="GetLastTradePrice"> <input message="tns:GetLastTradePriceInput"/> <output message="tns:GetLastTradePriceOutput"/> </operation> </portType>

  28. Operation Types • The request-response type is the most common operation type, but WSDL defines four types: • One-way: The operation can receive a message but will not return a response • Request-response:The operation can receive a request and will return a response • Solicit-response:The operation can send a request and will wait for a response • Notification:The operation can send a message but will not wait for a response • -- v 1.2 addition • request – multiple response …

  29. One way and Notification Example <portType name=“RegisterPort"> <operation name=“register"> <input name=“customerInfo" message=“RegInfo"/> </operation> <operation name = “register Response”> <output name = “response” message=“ResponseInfo”/> </operation> </portType >

  30. Binding • Binding defines how message are transmitted, and the location of the service.

  31. <binding name="StockQuoteSoapBinding" type="tns:StockQuotePortType"> <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> <operation name="GetLastTradePrice"> <soap:operation soapAction="http://example.com/GetLastTradePrice"/> <input> <soap:body use="literal"/> </input> <output> <soap:body use="literal"/> </output> </operation> </binding>

  32. <service name="StockQuoteService"> <documentation>My first service</documentation> <port name="StockQuotePort" binding="tns:StockQuoteBinding"> <soap:address location="http://example.com/stockquote"/> </port> </service>

  33. A Very Simple Example: Echo public class echoService implements echoServiceInterface{ public String echo(String msg) { return msg; } public static void main(String[] args) { new echoService().echo(“hello”); } }

  34. The Echo Interface /** * All implementers of this interface must * implement the echo() method. */ public interface echoServiceInterface { public String echo(String toEcho); }

  35. Now Use Echo As A Remote Service • We can take the previous Java program and deploy it in Tomcat as a service. • Clients can then invoke the echo service. • WSDL tells them how to do it. • Clients don’t need to know anything about the service implementation or even language. • WSDL is the latest IDL • DCE and CORBA IDL were two older examples. C# Client WSDL SOAP(Echo “hello”) “hello” WSDL Tomcat+ Axis+Echo

  36. The Main Structure of WSDL <definition namespace = “http/… “> <type> xschema types </type> <message> … </message> <port> a set of operations </port> <binding> communication protocols </binding> <service> a list of binding and ports </service> <definition>

  37. What Does echoServiceInterface Look Like In WSDL? <?xml version="1.0" encoding="UTF-8" ?> <wsdl:definitions targetNamespace="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" xmlns:intf="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">   <wsdl:types /> <wsdl:message name="echoResponse">   <wsdl:part name="echoReturn" type="xsd:string" />   </wsdl:message> <wsdl:message name="echoRequest">   <wsdl:part name="in0" type="xsd:string" />   </wsdl:message> <wsdl:portType name="Echo"> - <wsdl:operation name="echo" parameterOrder="in0">   <wsdl:input message="impl:echoRequest" name="echoRequest" />   <wsdl:output message="impl:echoResponse" name="echoResponse" />   </wsdl:operation>   </wsdl:portType>

  38. What Does This Look Like In WSDL? <wsdl:binding name="EchoSoapBinding" type="impl:Echo"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" /> <wsdl:operation name="echo">   <wsdlsoap:operation soapAction="" /> <wsdl:input name="echoRequest">   <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" use="encoded" />   </wsdl:input> <wsdl:output name="echoResponse">   <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding namespace="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" use="encoded" />   </wsdl:output>   </wsdl:operation>   </wsdl:binding> <wsdl:service name="EchoService"> <wsdl:port binding="impl:EchoSoapBinding" name="Echo">   <wsdlsoap:address location="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" />   </wsdl:port>   </wsdl:service> </wsdl:definitions>

  39. Did I Write That WSDL by Hand? • Are you kidding? • It was automatically generated by axis. Most other Web service tools will do the same. • See other tutorial for generated WSDL. • We will go through the construction, though, for understanding.

  40. WSDL Parts • Types • Used to define custom message types • Messages • Abstraction of request and response messages that my client and service need to communicate. • PortTypes • Contains a set of operations. • Operations organize WSDL messages. • Operation->method name, PortType->java interface • Bindings • Binds the PortType to a specific protocol (typically SOAP over http). • You can bind one PortType to several different protocols by using more than one port. • Services • Gives you one or more URLs for the service. • Go here to execute “echo”.

  41. Echo Service WSDL, Section by Section

  42. The WSDL Schema • See http://www.w3.org/TR/wsdl for the official recommendation. • The full WSDL schema is given here. • We focus on a specific example.

  43. Front Matters <?xml version="1.0" encoding="UTF-8" ?> <wsdl:definitions targetNamespace="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" xmlns:intf="http://grids.ucs.indiana.edu:8045/GCWS/services/Echo" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  44. Namespaces • The WSDL document begins with several XML namespace definitions. • Namespaces allow you to compose a single XML document from several XML schemas. • Namespaces allow you to identify which schema an XML tag comes from. • Avoids name conflicts. • As we will see, the Axis namespace generator went overboard. • Not all of these are used.

  45. Namespace Quiz • What is the default namespace of our XML doc? • What does <wsdl:definitions …> mean? • What does xmlns:xsd=http://www.w3.org/2001/XMLSchema mean? • Is http://www.w3c.org/2001/XMLSchema a URI or a URL? • What is the target namespace of this document? • What is the target namespace used for?

  46. Quiz Answers • http://schemas.xmlsoap.org/wsdl/ • This means <definitions> belongs to the schema named http://schemas.xmlsoap.org/wsdl/, labeled wsdl: in this doc. • It means that elements from the XML schema that appear in this WSDL document will be labled by <xsd:…> • Technically, it is used here as a URI; that is, it is a structured name. The URL does exist, however. • Recall URLs are special cases of URIs. URIs are names/identifiers. URLs also have a specific location on the web. • http://grids.ucs.indiana.edu:8045/GCWS/services/Echo • The target namespace is the namespace that will be used when we validate the document. • Note this isn’t used in our document since we define no complex types of our own. • See next section.

  47. WSDL Types

  48. WSDL Types • EchoService just has string messages. • So no special types definitions are needed in our WSDL. • Strings are an XML schema built-in type. • See earlier XML lectures.

  49. Schema Built In Types

  50. When Would I Need A Type? • Any time your Web Service needs to send data formatted by anything other than XML built-in types, you must define the type in WSDL. • Example: Arrays are not built-in types! • Arrays of strings, ints, etc., must be defined in the WSDL <type></type> structure.

More Related