150 likes | 238 Views
Agenda. WSDL & XML Schema. An Order. <?xml version=“1.0” encoding=“UTF-8”?> <Order> <OrderID> 10200341 </OrderID> <Customer> <CustomerID> 100347 </CustomerID> </Customer> <TotalPrice currency=“ SKK ”> 3400 </TotalPrice> <Items> <Item> <ProductID> 491 </ProductID>
E N D
Agenda • WSDL & XML Schema
An Order <?xml version=“1.0” encoding=“UTF-8”?> <Order> <OrderID>10200341</OrderID> <Customer> <CustomerID>100347</CustomerID> </Customer> <TotalPrice currency=“SKK”>3400</TotalPrice> <Items> <Item> <ProductID>491</ProductID> <Quantity>100</Quantity> <UnitPrice currency=“SKK”>34</UnitPrice> </Item> ... </Items> <Shipping> <ShipTo>Astronomicko-geofyzikálne observatórium, 920 01 Modra</ShipTo> </Shipping> </Order>
Service 1: GetCustomerDetails Input: HTTP POST to http://crmserver.acme.org/custinfo <?xml version=“1.0” encoding=“UTF-8”?> <GetCustomerDetails> <ID>100347</ID> </GetCustomerDetails> Output: HTTP data returned <?xml version=“1.0” encoding=“UTF-8”?> <GetCustomerDetailsReply> <ID>100347</ID> <Type>CORP</Type> <Level>GOLD</Level> <Name>Fakulta matematiky, fyziky a informatiky UK</Name> <Address>Mlynská dolina, 84248 Bratislava</Address> <Status>OK</Status> </GetCustomerDetailsReply>
CustomerServiceoperation: GetCustomerInformation Input: <?xml version=“1.0” encoding=“UTF-8”?> <c:ID xmlns:c=“http://xml.uniba.sk/is/customer”>100347</c:ID> Output: <?xml version=“1.0” encoding=“UTF-8”?> <c:CustomerInformation xmlns:c=“http://xml.uniba.sk/is/customer”> <c:ID>100347</c:ID> <c:Type>CORP</c:Type> <c:Level>GOLD</c:Level> <c:Name>Fakulta matematiky, fyziky a informatiky UK</c:Name> <c:Address>Mlynská dolina, 84248 Bratislava</c:Address> <c:Status>OK</c:Status> </c:CustomerInformation>
WSDL Web Services Description Language describes format of messages received and sent by the service at abstract level (messages, operations, port types) at concrete level(bindings, ports, services) optionally specifies also policies e.g. “this service requires authentication done by WS-Security, specifically X.509 certificates” specified in WS-PolicyAttachment
WSDL: abstract description interface (port type) consists of operations operation consists of messages input, [output], [fault(s)] message consists of parts part is specified as an element or a type in XML Schema
<wsdl:definitions ...> <wsdl:types> <xsd:schema ...> <xsd:element name="A" type="xsd:integer"/> <xsd:element name="B" type="xsd:integer"/> <xsd:element name="C" type="xsd:integer"/> </xsd:schema> </wsdl:types> <wsdl:message name="Input"> <wsdl:part name="A" element="tns:A"/> <wsdl:part name="B" element="tns:B"/> </wsdl:message> <wsdl:message name="Output"> <wsdl:part name="C" element="tns:C"/> </wsdl:message> <wsdl:portType name="CalculatorInterface"> <wsdl:operation name="Sum"> <wsdl:input message="tns:Input“/> <wsdl:output message="tns:Output“/> </wsdl:operation> </wsdl:portType>
CustomerServiceoperation: GetCustomerInformation Input: <?xml version=“1.0” encoding=“UTF-8”?> <c:ID xmlns:c=“http://xml.uniba.sk/is/customer”>100347</c:ID> Output: <?xml version=“1.0” encoding=“UTF-8”?> <c:CustomerInformation xmlns:c=“http://xml.uniba.sk/is/customer”> <c:ID>100347</c:ID> <c:Type>CORP</c:Type> <c:Level>GOLD</c:Level> <c:Name>Fakulta matematiky, fyziky a informatiky UK</c:Name> <c:Address>Mlynská dolina, 84248 Bratislava</c:Address> <c:Status>OK</c:Status> </c:CustomerInformation>
<wsdl:definitions ...> <wsdl:types> ... </wsdl:types> <wsdl:message name="GCIRequest"> <wsdl:part name="ID" element="c:ID"/> </wsdl:message> <wsdl:message name="GCIResponse"> <wsdl:part name="CustomerInformation“ element="c:CustomerInformation"/> </wsdl:message> <wsdl:portType name="GetCustomerInformationPortType"> <wsdl:operation name="GetCustomerInformation"> <wsdl:input message="tns:GCIRequest"/> <wsdl:output message="tns:GCIResponse"/> </wsdl:operation> </wsdl:portType>
XML Schema • schema– a document that describes a set of compliant XML documents (instances of this schema) • describeselements and their attributes (using types) • types are: • simple (attributes and text-only elements) • complex (elements with subelements and/or attributes) • simple types: • predefined • derived (e.g. by restriction) • complex types are defined by: • attributes and/or subelements (list, cardinality, default values, ...) • extension (≈ inheritance) • ...
string, normalizedString, token base64Binary hexBinary integer [non]positiveInteger [non]negativeInteger [unsigned][long|int|short|byte] decimal, float, double boolean dateTime, date, time duration gYear, gYearMonth, gMonth, gMonthDay, gDay Name QName NCName anyURI language ID, IDREF, IDREFS, ENTITY, ENTITIES, NOTATION, NMTOKEN, NMTOKENS XML Schema (2)simple types examples
XML Schema (3) <xsd:element name=“pricelist”> <xsd:complexType> <xsd:sequence minOccurs=“0” maxOccurs=“unbounded”> <xsd:element name=“coffee”> <xsd:complexType> <xsd:sequence> <xsd:element name=“name” type=“xsd:string”/> <xsd:element name=“price” type=“xsd:int”/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> <pricelist> <coffee> <name>Nescafé</name> <price>167</price> </coffee> <coffee> <name>Jacobs</name> <price>213</price> </coffee> </pricelist>
<wsdl:types> <xsd:schema elementFormDefault="qualified" targetNamespace="http://xml.uniba.sk/is/customer" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <xsd:element name="ID" type="xsd:string"/> <xsd:element name="CustomerInformation"> <xsd:complexType> <xsd:sequence> <xsd:element name="ID" type="xsd:string"/> <xsd:element name="Type" type="xsd:string"/> <xsd:element name="Level" type="xsd:string"/> <xsd:element name="Name" type="xsd:string"/> <xsd:element name="Address" type="xsd:string"/> <xsd:element name="Status" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> </wsdl:types>
WSDL: concrete description binding specifies concrete protocol (SOAP 1.1, HTTP, MIME) specifies details, e.g. for SOAP 1.1: how parts are mapped to SOAP Headers and/or SOAP Body call style: documentorrpc encoding: literalor encoded transport (e.g. HTTP, SMTP, JMS) service subelements port that specify physical addresses (e.g. URLs) at which individual bindings are reachable
<wsdl:binding name="SOAPBinding“ type="tns:GetCustomerInformationPortType"> <soap:binding style="document“ transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="GetCustomerInformation"> <soap:operation soapAction="http://xml.uniba.sk/is/customer/GetCustomerInformation"/> <wsdl:input> <soap:body use="literal"/> </wsdl:input> <wsdl:output> <soap:body use="literal"/> </wsdl:output> </wsdl:operation> </wsdl:binding> <wsdl:service name="CustomerService"> <wsdl:port name=“CustomerServicePort“ binding="tns:SOAPBinding"> <soap:address location="http://localhost:2580/process/GetCustomerInformation"/> </wsdl:port> </wsdl:service> </wsdl:definitions>