Click here to Skip to main content
15,860,972 members
Articles / Programming Languages / C#
Article

WSDL and Schema Parser

Rate me:
Please Sign up or sign in to vote.
4.82/5 (18 votes)
25 Nov 20054 min read 162.5K   5.5K   62   30
Modeling WSDL and XML schema on a TreeView control and generating XML document from XML schemas.

Image 1

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


Written By
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

 
QuestionWSDL 2.0 Pin
mlcalache8-Jul-17 4:25
mlcalache8-Jul-17 4:25 
Questionsoap xml Pin
schalla1237-May-13 5:57
schalla1237-May-13 5:57 
SuggestionTo improve performance Pin
Satyacbit24-Apr-12 22:49
Satyacbit24-Apr-12 22:49 
QuestionCan't find the TreeNode.Tag object in C#.Net Pin
disney67512-Apr-12 16:56
disney67512-Apr-12 16:56 
GeneralMy vote of 5 Pin
Manoj Kumar Choubey15-Feb-12 23:34
professionalManoj Kumar Choubey15-Feb-12 23:34 
QuestionSilverlight Pin
uugii5556-Dec-11 17:05
uugii5556-Dec-11 17:05 
QuestionCan I parse local files? Pin
techstress18-Feb-11 5:38
techstress18-Feb-11 5:38 
GeneralWSDL parser to extract types and their facets from a WSDL document Pin
sruthi116-Jul-08 14:10
sruthi116-Jul-08 14:10 
GeneralDerivative/Extension works Pin
Santosh Benjamin15-Mar-08 10:50
Santosh Benjamin15-Mar-08 10:50 
GeneralRe: Derivative/Extension works Pin
Thanh Dao6-Jun-08 4:12
Thanh Dao6-Jun-08 4:12 
GeneralRe: Derivative/Extension works Pin
rohith shenoy19-Apr-12 8:02
rohith shenoy19-Apr-12 8:02 
Generalparse SOAP Header Pin
Atanu GB19-Aug-07 20:32
Atanu GB19-Aug-07 20:32 
GeneralDemo & code no longer in sync Pin
brigw141-May-07 12:45
brigw141-May-07 12:45 
AnswerRe: Demo & code no longer in sync Pin
ipsharer27-Feb-09 5:41
ipsharer27-Feb-09 5:41 
GeneralRe: Demo & code no longer in sync Pin
Robert E. Tjia17-Mar-09 5:42
Robert E. Tjia17-Mar-09 5:42 
GeneralRe: Demo & code no longer in sync Pin
DJ_SG8-May-11 23:48
DJ_SG8-May-11 23:48 
GeneralWSDL parsing Pin
rorobisso4-Apr-07 1:21
rorobisso4-Apr-07 1:21 
QuestionHow I can send credentials for authentication? Pin
Dock196-Sep-06 7:31
Dock196-Sep-06 7:31 
AnswerRe: How I can send credentials for authentication? Pin
Dock196-Sep-06 9:17
Dock196-Sep-06 9:17 
AnswerRe: How I can send credentials for authentication? Pin
dan p27-Feb-08 11:25
dan p27-Feb-08 11:25 
GeneralGenerated Xml to Soap Request Pin
[V]GreyWolf5-Sep-06 13:44
[V]GreyWolf5-Sep-06 13:44 
QuestionsimpleTypes? Pin
Linski24-May-06 23:08
Linski24-May-06 23:08 
AnswerRe: simpleTypes? [modified] Pin
Thanh Dao25-May-06 4:00
Thanh Dao25-May-06 4:00 
General.net 2.0 Pin
Antonio Chagoury21-May-06 6:48
Antonio Chagoury21-May-06 6:48 
GeneralRe: .net 2.0 Pin
Thanh Dao25-May-06 4:16
Thanh Dao25-May-06 4:16 

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

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