1 / 17

More on XML XML Schema Definition Language (XSD)

More on XML XML Schema Definition Language (XSD). XML Schema Definition Language (XSD). Introduced in 2001 as a standard by W3C organization. Defines the XML schema, the base for all XML “languages” such as WSDL, WSDD, … Defines a set of predefined (built-in) types such as int, string.

tino
Download Presentation

More on XML XML Schema Definition Language (XSD)

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. More on XMLXML Schema Definition Language (XSD)

  2. XML Schema Definition Language (XSD) • Introduced in 2001 as a standard by W3C organization. • Defines the XML schema, the base for all XML “languages” such as WSDL, WSDD, … • Defines a set of predefined (built-in) types such as int, string. • Provides a means of defining new data types. • Describes the structure of XML documents.

  3. Compare to a programming language, say Java. XML Schema Definition Language. XSD Compare to Java class definitions used for a particular application. An XML schema for a particular application. Example WSDL schema Compare to an object instance from above class Example WSDL document for a service A document conforming to a particular schema

  4. Standard data types Correspond to “primitive” datatypes in a high level language. Specific sizes and form. Example type = xsd:int Such attributes would appear in an XML document to define the types of operands used when a a service is invoked.

  5. In an WSDL document, datatypes would appear in the message definitions: <wsdl:message name="squaredRequest"> <wsdl:part name="in0" type="xsd:int"/> </wsdl:message>

  6. Complex datatypes • Used to represent structured datatypes, similar to that of high level language. • A structure is defined consisting of defined datatypes. Example <complexType name=“student”> <sequence> <element name=StudentName” type=“xsd:string”/> <element name=“StudentID” type=“xsd:int”/> <element name=“Login” type=“xsd:string”/> </sequence> </complexType>

  7. Derived datatypes • Can “derive data types from “primitive” datatypes, using one of three mechanisms, restriction, extension, and list. Example • Can restrict a datatype to have certain values.

  8. From http://www.w3.org/ Built-in Built-in derived

  9. XML namespaces • Purpose to prevent naming collisions in elements and attribute names1. Must be a URI (often a URL), but only used as unique string. Example of a default namespace xmlns=“http://www.w3.org/2001/XMLSchema” Example of a namespace applied to certain names (using prexfix myns) xmlns:myns=“http://www.cs.uncc.edu/~abw/ns” 1. “Real World XML Web Services: For VB and VB .net Deveopers” by Y. Shohoud, online on http://www.learnxmlws.com.

  10. Assignment 1 WSDL example <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://DefaultNamespace" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://DefaultNamespace" xmlns:intf="http://DefaultNamespace" 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">

  11. Assignment 1 WSDL example <wsdl:definitions . . . xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:wsdl=“http://schemas.xmlsoap.org/wsdl/” xmlns:wsdlsoap=“http://schemas.xmlsoap.org/wsdl/soap/” xmlns:xsd="http://www.w3.org/2001/XMLSchema" . . . >

  12. WSDL file for myMath service Namespaces <wsdl:message name="squaredRequest"> <wsdl:part name="in0" type="xsd:int"/> </wsdl:message> <wsdl:message name="squaredResponse"> <wsdl:part name="squaredReturn" type="xsd:int"/> </wsdl:message> <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions targetNamespace="http://DefaultNamespace" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://DefaultNamespace" xmlns:intf="http://DefaultNamespace" 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"> Message definitions <wsdl:portType name="MyMath"> <wsdl:operation name="squared" parameterOrder="in0"> <wsdl:input message="impl:squaredRequest" name="squaredRequest"/> <wsdl:output message="impl:squaredResponse" name="squaredResponse"/> </wsdl:operation> </wsdl:portType> portType <wsdl:binding name="MyMathSoapBinding" type="impl:MyMath"> <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="squared"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="squaredRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded"/> </wsdl:input> <wsdl:output name="squaredResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://DefaultNamespace" use="encoded"/> </wsdl:output> </wsdl:operation> </wsdl:binding> Bindings Service definitions <wsdl:service name="MyMathService"> <wsdl:port binding="impl:MyMathSoapBinding" name="MyMath"> <wsdlsoap:address location="http://localhost:8080/axis/testaccount/ MyMath"/> </wsdl:port> </wsdl:service> </wsdl:definitions>

  13. Sample places for WSDL namespace xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" <wsdl:binding name="MyMathSoapBinding" type="impl:MyMath"> <wsdlsoap:binding style="rpc“ transport= "http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="squared"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="squaredRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="http://DefaultNamespace" use="encoded"/> </wsdl:input> <wsdl:output name="squaredResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="http://DefaultNamespace" use="encoded"/> </wsdl:output> </wsdl:operation> </wsdl:binding>

  14. Sample places for SOAP namespace xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" <wsdl:binding name="MyMathSoapBinding" type="impl:MyMath"> <wsdlsoap:binding style="rpc“ transport= "http://schemas.xmlsoap.org/soap/http"/> <wsdl:operation name="squared"> <wsdlsoap:operation soapAction=""/> <wsdl:input name="squaredRequest"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="http://DefaultNamespace" use="encoded"/> </wsdl:input> <wsdl:output name="squaredResponse"> <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/ encoding/" namespace="http://DefaultNamespace" use="encoded"/> </wsdl:output> </wsdl:operation> </wsdl:binding>

  15. More on schemas • One can create your own schema to match your web service application. Example Suppose you want to have purchase order system, with a schema for the invoices.

  16. Invoice schema <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.xmltc.com/railco/invoice/schema/"> <xsd:element name="InvoiceType"> <xsd:complexType> <xsd:sequence> <xsd:element name="Number" type="xsd:integer"/> <xsd:element name="Total" type="xsd:double"/> <xsd:element name="Date" type="xsd:date"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> Could save as file “Invoice.xsd”

  17. Purchase order <definitions name="InvoiceProcessing" … namespaces <types> <xsd:schema targetNamespace="http://www.xmltc.com/railco/invoiceservice/schema/"> <xsd:import namespace="http://www.xmltc.com/railco/invoice/schema/" schemaLocation="Invoice.xsd"/> <xsd:element name="SubmitInvoiceType"> <xsd:complexType> <xsd:sequence> <xsd:element name="ContextID" type="xsd:integer"/> <xsd:element name="InvoiceLocation" type="xsd:string"/> <xsd:element name="InvoiceDocument" type="inv:InvoiceType"/> </xsd:sequence> </xsd:complexType> </xsd:element> /xsd:schema> </types> <message name="receiveSubmitMessage"> <part name="RequestParameter" element="invs:SubmitInvoiceType"/> </message> <portType name="InvoiceProcessingInterface"> <operation name="Submit"> <input message="tns:receiveSubmitMessage"/> </operation> </portType> … bindings and sercive/ports </definitions>

More Related