90
13 November 2008 CIS 340 # 1 Co-Dependencies of Concepts

13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Embed Size (px)

Citation preview

Page 1: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

13 November 2008 CIS 340# 1

Co-Dependencies of Concepts

Page 2: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

13 November 2008 CIS 340# 2

What Does It Mean?

XWIF XML Web Services Integration Framework

SOAP Simple Object Access Protocol

Web service (WS)

•are application components •communicate using open protocols •self-contained and self-describing •can be used by other applications •XML as the base data structure

SOA Service Oriented Architecture

Page 3: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

13 November 2008 CIS 340# 3

What Does It Mean?

CORBA Common Object Request Broker Architecture Vendor-products offering ORB

DCOM Distributed Component Object ModelMicrosoft

SOAP Simple Object Access Protocol

WSDL Web Services Description Language

UDDI Universal Description, Discovery, and Integration

Registry for services

BPEL Business Process Execution Language

Page 4: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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 notnot imply forfeiture of loose coupling, autonomy, or abstraction

• Discoverability– Registry of service descriptions

Page 5: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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

Page 6: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

WSDL Introduction• WSDL contains information about the interface

semantics 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

Page 7: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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.

Page 8: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Working of WSDL (with Java)

Page 9: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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.

Page 10: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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/

Page 11: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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>

Page 12: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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

Page 13: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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.

Page 14: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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>

Page 15: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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>

Page 16: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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>

Page 17: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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>

Page 18: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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>

Page 19: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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>

Page 20: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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>

Page 21: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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>

Page 22: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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.

Page 23: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

<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>

Page 24: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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.

Page 25: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

<message name="GetLastTradePriceInput"> <part name="body" element="TradePriceRequest"/>

</message>

<message name="GetLastTradePriceOutput"> <part name="body" element="TradePrice"/>

</message>

Page 26: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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.

Page 27: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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

Page 28: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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 …

Page 29: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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 >

Page 30: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Binding

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

Page 31: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

<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>

Page 32: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

<service name="StockQuoteService"> <documentation>My first service</documentation>

<port name="StockQuotePort" binding="tns:StockQuoteBinding">

<soap:address location="http://example.com/stockquote"/> </port>

</service>

Page 33: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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”);}

}

Page 34: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

The Echo Interface

/*** All implementers of this interface must* implement the echo() method.*/public interface echoServiceInterface {

public String echo(String toEcho);}

Page 35: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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

Tomcat+Axis+Echo

WSDL

SOAP(Echo “hello”) “hello”

Page 36: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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>

Page 37: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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>

Page 38: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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/encodingnamespace="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>

Page 39: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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.

Page 40: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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”.

Page 41: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Echo Service WSDL, Section by Section

Page 42: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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.

Page 43: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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">

Page 44: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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.

Page 45: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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?

Page 46: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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.

Page 47: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

WSDL Types

Page 48: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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.

Page 49: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Schema Built In Types

Page 50: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

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.

Page 51: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

How Does WSDL Encode String Arrays?

• Imagine that my echo service actually echoes back an array of strings.

• Luckily for us, SOAP defines arrays, so we can import this definition.

• Next slide shows what this looks like.

Page 52: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

String Array Example<wsdl:types>

<schema targetNamespace="http://grids.ucs.indiana.edu:8045/GCWS/services/EchoArray"

xmlns="http://www.w3.org/2001/XMLSchema"> <import namespace="http://schemas.xmlsoap.org/soap/encoding/" /> <complexType name="ArrayOf_xsd_string">

<complexContent> <restriction base="soapenc:Array"> <attribute ref="soapenc:arrayType"

wsdl:arrayType="xsd:string[]" />   </restriction>  </complexContent>  </complexType>  <element name="ArrayOf_xsd_string" nillable="true"

type="impl:ArrayOf_xsd_string" />   </schema>  </wsdl:types>

Page 53: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

WSDL String Array Types

• WSDL <type> is nothing more than an extensibility placeholder in WSDL.

• Technically, the WSDL schema specifies that <type> </type> can contain a <sequence> of 0 or more <any> tags.

• And note that the <any> tag acts like wildcard.– You can insert any sort of xml here.

Page 54: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Inserting a Type• Between <type></type>, we insert an <schema>.• Since arrays are defined in SOAP encoding rules, I

next import the appropriate schema.– “Import” means replaces a simple cut-and-past of the

entire soap encoding schema.

• Next, insert our own local definition of a type called “ArrayOf_xsd_string”.

• This is a restricted extension of the SOAP Array complex type.– We only allow 1 dimensional string arrays– It is also nillable—I am allowed insert a “null” value for the

string.

Page 55: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Handling Other XML Types• You can also express other message arguments

as XML.– Examples: a purchase order, an SVG description of an

image, a GML description of a map.• In practice, these are handled by automatic Bean

serializers/deserializers.– Castor is an example: http://www.castor.org/– XMLBeans is another http://xml.apache.org/xmlbeans/

• These are tools that make it easy to convert between XML and JavaBeans.

• By “JavaBeans” I mean objects that associate simple get/set methods with all data.

• Implementation dependent.

Page 56: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

WSDL Messages

Page 57: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Our Echo Messages

<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>

Page 58: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Remember the Echo Service?

• Our echo service takes a string argument and returns a string answer.

• In WSDL, I first abstract these as messages.– Echo needs two messages.

• Note we have not yet said message is the request and which is the response.– That is the job of the portType operations,

coming up.

Page 59: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Structure of a Message• WSDL <message> elements have name attributes

and one or more parts.– The message name should be unique for the document.– <operation> elements will refer to messages by name.

• I need one <part> for each piece of data I need to send in that message.

• Each <part> is given a name and specifies its type.– <part> types can point to <wsdl:type> definitions if

necessary.– Our service just needs xsd:strings, so no problem.

Page 60: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

More Messages

• Our simple service only has one method. – What if it had echoEnglish(), echoSpanish(), and

echoFrench()?– Each takes a string in English and echoes back

the string in another language.• Then we would need 6 messages, each with one

part.

Page 61: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

portTypes and operations

Page 62: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

EchoService portType<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>

Page 63: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

WSDL portTypes

• WSDL messages are only abstract messages. – We bind them to operations within the portType.

• The structure of the portType specifies (still abstractly) how the messages are to be used.– Think of operations->java methods – and portTypes->java interfaces.

Page 64: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

portType Message Patterns• PortTypes support four types of messaging:

– One way: Client send a message to the service and doesn’t want a response.

• <input> only.– Request-Response: Client sends a message and waits for a

response. • <input>, then <output>

– Solicit-Response: Service sends a message to the client first, then the client responds.

• <output>, then <input>– Notification: <output> only.

• These still are abstract. We must implement them using some message protocol.– HTTP units of transmission are request and response, so

mapping Solicit-Response to HTTP will take some work.

Page 65: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

portType for EchoService

• The echo service has one method, echo. • It takes one string argument and returns

one string.• In WSDL, the portType is “Echo”, the

operation is “echo”. • The messages are organized into input and

output. – Messages are placed here as appropriate.– That is, <input> takes the <echoRequest>

message.

Page 66: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Parameter Order

• This attribute of operation is used to specify zero or more space-separated values.

• The values give the order that the input messages must be sent.

• Echo is a bad example, since it only has one input parameter, named in0.

Page 67: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

WSDL Self-Referencing

• The WSDL <input> and <output> tags need to point back to the <message> definitions above:

<wsdl:message name="echoResponse">  <wsdl:part name="echoReturn" type="xsd:string" />  </wsdl:message>…<wsdl:portType name="Echo">

<wsdl:operation name="echo" parameterOrder="in0">  …  <wsdl:output message="impl:echoResponse"

name="echoResponse" />   </wsdl:operation>  </wsdl:portType>

Page 68: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

The Picture So Far…

Part

Input Message

Part

Input Message

PartPart

Output Message

portType

Operation

Input

Ouput

hasInput

hasOutput

Page 69: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

WSDL Interior References

• WSDL decouples messages from the operations that use them– Messages-> method parameter lists and return

types.– Operations-> java methods

• This is some tricky XML schema syntax: keys, selectors, fields, and QNames.

• This is actually an important problem.– RDF (an XML dialect) has an alternative way to do

these associations.– RDF is another lecture.

Page 70: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

WSDL Schema Keys, Fields, and Selectors

<element name="definitions" type="wsdl:definitionsType"> <key name="message">

<selector xpath="message"/> <field xpath="@name"/>

</key> <key name="portType">

<selector xpath="portType"/> <field xpath="@name"/>

</key> <key name="binding">

<selector xpath="binding"/> <field xpath="@name"/>

</key>…

</element>

Page 71: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

What Does This Mean?

• The key-selector-field construction is used by XML Schemas to constrain values.– Must be unique– Cannot be nilled.

• Previous syntax means that the “name” attribute of any tag must be unique in any instance documents.– You can’t have two portTypes with the same

name.

Page 72: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Using QNames for References• Operation’s input and output

tags all derive from <paramType>.

• These have an attribute named “message” that must be a QName that appears elsewhere in the document.

• Recall a QName is an element name.

– Without a namespace, it points only to an element name within the document.

• Coupled with the <key> elements, we insure message values point to unique elements.

• Not really elegant or even foolproof, is it?

<complexType name="paramType“

<complexContent> <extension

base="wsdl:documented"> <attribute name="name" type="NMTOKEN" use="optional"/> <attribute

name="message" type="QName"

use="required"/> </extension> </complexContent></complexType>

Page 73: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Bindings

Page 74: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

So Far…

• We have defined abstract messages, which have XML values.– Simple or custom-defined types.

• We have grouped messages into operations and operations into portTypes.

• We are now ready to bind the portTypes to specific protocols.

Page 75: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

The Binding for Echo

<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=“…" use="encoded" />

  </wsdl:input> <wsdl:output name="echoResponse">  <wsdlsoap:body

encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace=“…" use="encoded" />

  </wsdl:output> </wsdl:operation></wsdl:binding>

Page 76: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Binding tags

• Binding tags are meant to bind the parts of portTypes to sections of specific protocols.– SOAP, HTTP GET/POST, and MIME are

provided in the WSDL specification.• Bindings refer back to portTypes by name, just as

operations point to messages.

Page 77: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

WSDL Internal References

portType

Operation

Input

Ouput

binding

Operation

Input

Ouput

Page 78: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Structure of the Binding

• <binding> tags are really just placeholders.• They are meant to be extended at specific

places by wsdl protocol bindings.– These protocol binding rules are defined in

supplemental schemas.• The following box figure summarizes these

things– Green boxes are part of WSDL

• From the wsdl namespace, that is.– Red boxes are parts of the document from other

schemas• From wsdlsoap namespace in the echo example.

Page 79: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Binding Structure

binding

Non-wsdl extension

operation

Non-wsdl extension

input output

Non-wsdl extension

Non-wsdl extension

Page 80: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

SOAP Bindings

• The WSDL bindings are meant to prescribe how the parts of the portType get transported.

• All the given bindings are to parts of SOAP messaging formats.– WSDL’s SOAP bindings define mappings. – We will look at these in upcoming lectures.

Page 81: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

For now, note the following• We specify SOAP encoding• SOAP is a message format and needs a transport

protocol, so we specify HTTP.• Operation styles may be either “RPC” or

“Document”. – We use RPC.

• SOAP Body elements will be used to actually convey message payloads.– RPC requires “encoded” payloads.

• Each value (echo strings) is wrapped in an element named after the operation.

• Useful RPC processing on the server side.– Documents are literal (unencoded)

• Use to just send a payload of XML inside SOAP.

Page 82: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Binding Associations to SOAP

Binding SOAP RPC

Operation

WSDL SOAP

SOAP Action

Input

Output

SOAP Body

SOAP Body

Page 83: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Binding Restrictions

• Binding elements point by name to portTypes.

• WSDL allows more than one binding element to point to the same port type.– Why?– Because a service may support

multiple, alternative protocol bindings.

Page 84: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

What Does It Mean?• WSDL is not a programming language. • A service that exposes an WSDL interface is just

telling a client what it needs to do to communicate with the service.– Send me strings and I will return strings. – I expect SOAP messages that include the strings in the

body. – I expect this body to be RPC encoded with the operation

name so that I will know which operation the body contents belong to.

– I will return SOAP messages that include Strings in the body. – These will also be encoded so that you know what to do with

them.

Page 85: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Ports and Services

Page 86: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Ports and Services

<wsdl:service name="EchoService">

<wsdl:port binding="impl:EchoSoapBinding" name="Echo"> <wsdlsoap:address

location=“http://..../"/>

  </wsdl:port>

</wsdl:service>

Page 87: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Port and Service Tags

• The service element is a collection of ports.– That’s all it is for.

• Ports are intended to point to actual Web service locations– The location depends on the binding.– For SOAP bindings, this is a URL.

Page 88: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Ports and Services

• A service can have more than one port.• Two ports can point back to the same binding

element.– Ports refer to bindings by name– This allows you to provide alternative service

locations.

• The figure on next slide conceptually depicts associating two ports to a single binding.– The ports differ only in the URLs of their services.

Page 89: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Port Associations to Bindings

Binding Service

OperationPort #1

Input

Output

URL #1

URL #2

Port #2

Page 90: 13 November 2008CIS 340 # 1 Co-Dependencies of Concepts

Summary of WSDL

• WSDL decouples remote service operations.– Types=custom message definitions.

• Any data types not in the XML schema.

– Message=name the messages that must be exchanged and their data types, possibly defined by <type>.

– PortTypes=service interfaces• Operations=remote method signatures.

– Bindings=mappings of portType operations to real message formats

– Ports=locations (URLs) of real services.