Click here to Skip to main content
Click here to Skip to main content

WSDL and Schema Parser

, 25 Nov 2005
Rate this:
Please Sign up or sign in to vote.
Modeling WSDL and XML schema on a TreeView control and generating XML document from XML schemas.

Introduction

If you want to aggregate a web service with your application service, or if you are trying to implement someone else's WSDL, then you need to pay attention while viewing them. That means you are encountering the web service interoperability problem. That was the problem I had too, and I thought that having a GUI for viewing a WSDL like tree structure could be really cool.

In my previous article on UDDI Explorer, I presented an approach for searching the web service and parsing the web service description information (WSDL). It focused on UDDI and parsing the abstraction (interface) level of WSDL. I sometimes encounter questions that fall into the same idea of parsing WSDL that also takes into account the implementation of the information level.

In addition to refactoring, this library was developed to patch up the known bugs of the previous article. It aims to achieve better result by improving some features like:

  • Bottom-up parsing of WSDL document.
  • Collection based parsing of XML schema.
  • Generating XML document from XML schema.

Background

If you are not familiar with WSDL, SOAP, XML schema, then before going further please check out these resources:

Parsing the WSDL

As you can see, the WSDL can be represented as a tree structure. The parsing task includes two major modules: WSDL parser and the XML schema parser. The WSDL parsing task goes from the implementation level up to the abstraction level. The parser proceeds as follows:

  • For clarity, we first get all the <service> elements. For each <service> element, we jump to the <Binding> element that matches the service, and get the set of operations that the <binding> element includes, and then jump to the <PortType> definition which the <binding> element points to.
  • Finally, we find the operations set of the <PortType> element. Parsing such operations is based on the binding information (style, use attributes) and the input/output message declaration associated with them. This process also takes into account parsing of the associated XML schema.

The XML schema parser module includes a process that translates the XML schema structure into a tree that looks like the XML instance of each SOAP message. It is featured in detail below:

  • Reference type definition

    Reference definition is a mechanism to make schema simple through the sharing of common segments/types. In the process of transforming this structure into a tree, I chose to duplicate the shared segment under the node that refers to it.

  • Preventing infinite recursive definition

    This happens when a leaf element refers to one of its ancestors. (I.e. A class has a member as an instance of it.) This structure definition will also break the tree structure and it has to be solved differently from the way of solving reference types, otherwise it will fall into an infinite recursive loop. In this case, it just shows the node (which refers to its ancestors) with a predefined depth.

  • Handling multiple schema elements

    This occurs when an element has an unbounded value for the maxOccur attribute. It will be treated by duplicating the same element.

  • Handling the inherit definition

    A complexType which is defined based on other types will be built as the derived structure. That means the derived node contains the base node elements.

  • Handling the namespace

    If an element form is qualified, the XML element should be displayed in the qualified name.

It turns out that there is no easy way to do parsing of the XML schema due to its structure which is extremely rich and complex. Due to the declaration difference between the operation styles of Document/RPC, the input/output tree might be different. We can extend the result of XML schema parser to solve the problem of generating XML document from XML schemas.

Using the library

The view displays the service name, protocol, port, the collection of operations that are exposed by the port and their parameters. Depending on the complexity of WSDL and the server status, the TreeView may take a few seconds to render. Move your cursor over any operation element to view the input/output parameters associated with it.

This library contains two major parser modules as mentioned above. The extra module helps you to create XML from a tree node; in this case it generates XML data from the XML schema tree. You can use them in both 1.1 or 2.0 Framework.

I've tested it on some quite big web services with size larger than 10000 lines and with a complex schema definition, by just entering the web service address and clicking the Parse button. Now, let's take a look at how the tree looks like!

Conclusion

Web services are still growing up and going to play an important role in distributed computation. However, there are many misconceptions that exist in this technology. At the basic level, this tool can partially help you in creating the business process. I will stop for now and expect to have more time to enrich the explanation.

My special thanks to Marc Clifton and Lluis Sanchez for their works on XSD and WSDL generation that helped me in saving my time for implementing such things.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Thanh Dao
Software Developer
Vietnam Vietnam
I'm still alive...but temporarily moved to work on mobile & web stuffs(j2me/brew/php/flash...something not M$). things have just been very busy, and probably will continue...so don't have chance to maintain & respond. Hope will have time to try to write again, because many ideas with WPF &silver light are waiting. wish me luck Smile | :)
 
FYI:
- MESHSimPack project(c# library for measuring similarity among concepts of the MESH ontology):
http://sourceforge.net/projects/meshsimpack.

Comments and Discussions

 
QuestionCan't find the TreeNode.Tag object in C#.Net Pinmemberdisney67512-Apr-12 17:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141223.1 | Last Updated 25 Nov 2005
Article Copyright 2005 by Thanh Dao
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid