How to Import XSD Into WSDL

How to Import XSD Into WSDL thumbnail
Import XSD Into WSDL

Web service description language (WSDL) is a model and format for describing web services using XML. A consumer can locate a service and execute its operations. This process can be automated using most common development tools, enabling application integration with little developer produced code. WSDLs are a contract between the service provider and consumer; it makes a service self-describing. WSDLs provide descriptions of all public operations, data types for all service messages, binding details for the transport protocol and service address information. An "import" element can be used in a WSDL to import external WSDLs or XML schemas. Importing external items is useful for allowing the WSDL to be more modular, reuse of XML data types among multiple service definitions and support multiple versions of a schema.

Things You'll Need

  • Text or XML editor
Show More

Instructions

    • 1

      Create new file in your text or XML editor. If the editor supports WSDLs, select WSDL as the file type. If it does not support WSDLs, but supports XML, select XML as the file type. If neither WSDLs or XML are supported, select a plain text file type.

    • 2

      Name the file with any name you desire, and give the file a ".wsdl" extension. For example, the file can be named "HelloWorld.wsdl."

    • 3

      Create a second new file in your text or XML editor. If the editor supports XML schemas, select XML schema or XSD as the file type. If it does not support XML schemas, but supports XML file, select XML as the file type. If neither XML schemas or XML are supported, select a plain text file type.

    • 4

      Name the file with any name you desire, and give the file a ".xsd" extension. For example, the file can be named "HelloWorld.xsd."

    • 5

      Enter the following markup in the XML schema file you created:

      <?xml version="1.0" ?>

      <xsd:schema targetNamespace="http://schemas.myorg.com/person/phone"

      xmlns:xsd="http://www.w3.org/2001/XMLSchema">

      <xsd:import namespace="http://www.w3.org/2001/XMLSchema"/>

      <xsd:complexType name="Phone">

      <xsd:sequence>

      <xsd:element name="areaCode" type="xsd:int"/>

      <xsd:element name="exchange" type="xsd:int"/>

      <xsd:element name="number" type="xsd:int"/>

      </xsd:sequence>

      </xsd:complexType>

      </xsd:schema>

      This defines a schema with the namespace "http://schemas.myorg.com/person/phone," which defines a single data type "Phone."

    • 6

      Enter the following markup in the WSDL file you created:

      <?xml version="1.0"?>

      <wsdl:description xmlns:wsdl="http://www.w3.org/ns/wsdl"

      xmlns:wsoap= "http://www.w3.org/ns/wsdl/soap"

      xmlns:external="http://schemas.myorg.com/person/phone"

      xmlns:helloWorld="http://schemas.myorg.com/wsdl/helloworld"

      targetNamespace="http://schemas.myorg.com/wsdl/helloworld">

      <wsdl:documentation>

      WSDL with an import example

      </wsdl:documentation>

      <wsdl:types>

      <xs:import namespace="http://schemas.myorg.com/person/phone"

      schemaLocation= "http://www.myorg.com/supporting/schemas/helloworld.xsd"/>

      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

      targetNamespace="http://schemas.myorg.com/wsdl/helloworld">

      <xsd:element name="CallNumber" type="external:Phone"/>

      <xsd:element name="HelloResponse" type="xsd:string"/>

      </xsd:schema>

      </wsdl:types>

      <wsdl:interface name="helloInterface" >

      <wsdl:operation name="CallMe"

      pattern="http://www.w3.org/ns/wsdl/in-out"

      style="http://www.w3.org/ns/wsdl/style/iri">

      <wsdl:input messageLabel="In"

      element="helloWorld:CallNumber" />

      <wsdl:output messageLabel="Out"

      element="helloWorld:HelloResponse" />

      </wsdl:operation>

      </wsdl:interface>

      <wsdl:binding name="helloBinding"

      interface="hy:helloInterface"

      type="http://www.w3.org/ns/wsdl/soap"

      wsoap:protocol="http://www.w3.org/2003/05/soap/bindings/HTTP/">

      <wsdl:operation ref="hy:Hello"

      wsoap:mep="http://www.w3.org/2003/05/soap/mep/soap-response"/>

      </wsdl:binding>

      <wsdl:service name="helloService"

      interface="hy:helloInterface">

      <wsdl:endpoint name="helloEndpoint"

      binding="hy:helloBinding"

      address="http://www.myorg.com/Service/Hello"/>

      </wsdl:service>

      </wsdl:description>

      This markup defines a WSDL that imports an external XML schema named "helloworld.xsd" which contains the namespace "http://schemas.myorg.com/person/phone."

      The import statement in the WSDL imports an XML namespace from a file. The primary purpose of the import element is to import the namespace, not to indicate where the declarations in the namespace can be found. The element includes the optional "schemaLocation" attribute. The attribute is optional because a namespace can be imported from the same file or be registered in another way. According the WSDL specification, "schemaLoction" is only a hint; an XML parser is free to ignore the location. If the parser already knows about the schema types in that namespace, or has another mechanism of finding them, it does not have to use the location. However, in many cases a namespace is imported that the XML parser knows nothing about, so the "schemaLocation" attribute becomes necessary, but technically it's still just a hint.

Tips & Warnings

  • New technologies such as metadata exchange, MEX, have been introduced to share information about what capabilities a service supports, but these standards have not yet been widely adopted.

  • WSDLs support includes and imports. They may sound similar, but they behave differently. An import statement imports another namespace. An include statement imports XML data type declarations into an existing namespace.

Related Searches:

References

  • Photo Credit Photos.com/Photos.com/Getty Images

Comments

You May Also Like

  • How to Generate Wsdl From Xsd

    XSD files are Extensible Markup Language (XML) schemas that help define a regular XML document, according to w3cschools.com. XSD files are also...

  • How to Use XSD in WSDL

    XSD and WSDL are XML schemas used to share functions with other programs. The schemas provide developers with an XML layout for...

  • The Difference Between XSD & WSDL

    XSD, which stands for XML Schema Definition, is the standard for defining the format of any given XML--Extensible Markup Language--file. Another acronym,...

  • How to Import an XSD File

    If most of the schema information you need is already contained within another XSD file, there is no reason to duplicate all...

  • How to Create Web Service in PHP

    Creating a Web Service in PHP involves developing a web application that handles SOAP data using standardized WSDL classes and function calls....

  • How to Generate an XSD File

    An XSD file is an Extensible Markup Language or XML schema that is used to define various elements and attributes of an...

  • How to Create Database Tables From XML and XSD Schemas

    The Filemaker Pro application is a database development tool that allows you to store multiple tables of data within a single file....

  • How to Use Class From XSD

    One of the features provided by the XSD tool released by Microsoft as part of the .NET Framework is the ability to...

  • How to Create Xsd

    A file with a XSD file extension is one that contains information relating to an XML file on your computer. Both file...

  • Example of the XSD File

    The file extension .xml is a text file that is commonly seen within XML schema. These files allow programmers and Web developers...

  • How to Generate a Class From XSD

    The Windows .NET framework that comes with all versions -- including the free Express versions -- of the Visual Studio development suite...

  • How to Create Web Service Client From Wsdl

    "Wsdl" refers to the XML-based web services definition language. Client-side code use interfaces to communicate (connect, pass and consume data) with the...

  • What Is the Difference Between XSL & XSD?

    The Difference Between XSD & WSDL. XSD, which stands for XML Schema Definition, is the standard for defining the format of any...

  • How to Generate an XSD From an XML File

    If you use XML data in your applications, it can be useful to have an XSD to check your structures against. XSD...

  • How to Read an XML From a Web Service

    You can write a web service that will read XML data. In fact, XML is the native format for web services in...

  • How to Create a Web Service Using Axis

    Axis is a SOAP engine -- a framework for constructing SOAP processors such as clients, servers and gateways. SOAP is a common...

  • How to Convert an XSD to an XML Tool

    The XSD schema created in your Visual Studio applications is the layout and "instructions" for the XML data. Visual Studio has a...

Related Ads

Featured