Understanding XML & XSD in SOAP webservice context

In the world of integration applications, we have been hearing about webservices mainly of types REST and SOAP. In general, a SOAP webservice publishes its definition file with WSDL (Webservice definition language) extension that belongs to XML (Extensible Markup Language) family. A typical webservice definition file contains details about services/operations, input & output definitions of these operations along with the network addresses. The input and output definitions are part of the WSDL and belong to XML family. As they are of family XML and defines a specific format, these files, if stored separately, uses XSD (XML schema definition) extension. In this post we will discuss basics of XML and XSD that are needed to work with webservices.

To consume a service defined in a webservice, users should have its definition WSDL file. While consuming the service, the input file has to follow the format defined by XSD inside the WSDL. Therefore, input XML, XSD and WSDL belong to XML family and the dependency moves in the direction of WSDL to XSD to XML. We will discuss about WSDL in detail in the next post. Any XML document should be well-formed in the sense every node should be closed properly. The nodes could be of type simple or complex. Complex node is a combination of a set of either simple or simple and complex nodes.

Figure 1 Simple element example from XSD file

Figure 2 Simple element example from input XML file

Figure 3 Complex element example from XSD file

Figure 4 Complex element example from input XML file

Usually in context of webservices input or output XMLs are well-formed and should be valid against the XSD definition. XMLs are created as per the definition provided by XSD file, that contains definition of simple and complex elements, their attributes and restrictions. To understand the relation between an XML and XSD consider a webservice that accepts as shown in below figure.

Figure 5 Relating XML and XSD elements

In this example inside XSD content the first node contains process instructions. Employee Information (EMPLOYEE_INFO) is a complex element of child elements – EMPLOYEE_ID, EMAIL_ADDRESS and MAIL_ADDRESS as input. Here MAIL_ADDRESS is another complex element containing further child elements. Each of these tags have proper logical closure, and therefore this XSD is well-formed. If you observer the element with name attribute equal to EMPLOYEE_ID, this element defines the data type to be an integer forcing the input XML defined over this XSD should have an integer value for element EMPLOYEE_ID.

Here the input XML on the right side of above figure is created based on the definition of XSD. As you can observe it is a well-formed document. In addition, this input XML document contains simple and complex elements with appropriate data types as forced by the XSD document. Therefore, this is a valid XML against the XSD document. We will discuss about WSDL in details in our next post.

13 thoughts on “Understanding XML & XSD in SOAP webservice context

  1. Leonardo Micciche

    Hey there would you mind sharing which blog platform you’re using? I’m planning to start my own blog soon but I’m having a difficult time selecting between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design and style seems different then most blogs and I’m looking for something completely unique. P.S My apologies for being off-topic but I had to ask!

  2. Pura Mallo

    Have you ever thought about publishing an e-book or guest authoring on other websites? I have a blog centered on the same subjects you discuss and would really like to have you share some stories/information. I know my audience would value your work. If you are even remotely interested, feel free to shoot me an e-mail.

  3. Snack Subscription

    Hi! This is my first comment here so I just wanted to give a quick shout out and say I really enjoy reading through your
    articles. Can you recommend any other blogs/websites/forums that go over
    the same subjects? Thank you!

Leave a Reply to Laronda Chumley Cancel reply

Your email address will not be published. Required fields are marked *