Click here to Skip to main content
13,196,946 members (83,936 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


12 bookmarked
Posted 16 Apr 2011

Validating SOAP Message against WSDL

, 8 Jun 2011
Rate this:
Please Sign up or sign in to vote.
A program that checks whether SOAP message conforms to WSDL


While developing our web service client, I received a message from the server that did not deserialize properly. It was rather large, and just by looking at it, I could not figure out what was wrong. It was obvious it is not conforming to the schema the client expects, but where?

I Googled it, and found that many people ask that same question: how do I check a SOAP message against WSDL? Surprisingly, there was no simple answer. I ended up checking the message in Eclipse IDE (we do some Java development too, so I had one installed). However, it required manually altering the message to add appropriate schema locations.

At this point, I decided to write a simple validator that would do this job automatically. Thanks to .NET built-in XML validation functionality, it is not very hard to do: all you need is to parse arguments and supply proper input to a validating XML reader.

Using the Code

Since downloading executables is forbidden in many companies, and compiling an executable is a hassle, I created the validator as a self-compiling .BAT file. Beginning of the file has some command line instructions for compilation, the rest is C# 2.0 source code. All you need is the .BAT file and .NET framework 2.0 or higher.

Since CodeProject does not allow uploading .BAT files, I renamed it to .TXT. Rename it back to .BAT after download. A precompiled executable is also available.

Using the code is straightforward:

SoapValidator message.xml contract.wsdl schema1.xsd schema2.xsd... 

All arguments except for the message file name are optional. If you supply "-" for file name, this means "read standard input".

The validator can check any XML document, not just SOAP messages. To make SOAP validation easier, the schema for the SOAP format itself (envelope, body, header) is built into the validator.

In additional to XSD schema files, the validator recognizes WSDL files with <schema> tags. If any schemas are imported, they must have valid schemalocation accessible to the validator.

Points of Interest

Self-compiling batch files or scripts are not a regular thing in .NET, while they are very common in UNIX. I find them useful, because they are not executable code per se (easier to get through firewalls and mail filters), and you don't need an IDE to compile them. I really wish Windows had the #! notation from UNIX, but alas.


  • 16th April, 2011: Initial post
  • 7th June, 2011: Replaced "exit" with "exit /B 0" on line 10 of SoapValidator.bat. This prevents it from closing the command prompt window.


This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0


About the Author

Ivan Krivyakov
Technical Lead Thomson Reuters
United States United States
Ivan is a hands-on software architect/technical lead working for Thomson Reuters in the New York City area. At present I am mostly building complex multi-threaded WPF application for the financial sector, but I am also interested in cloud computing, web development, mobile development, etc.

Please visit my web site:

You may also be interested in...

Comments and Discussions

QuestionERROR: Namespace not declared Pin
Member 1178638823-Jun-15 5:19
memberMember 1178638823-Jun-15 5:19 
QuestionNot telling me where the error is Pin
Member 85397564-Jan-12 8:03
memberMember 85397564-Jan-12 8:03 
AnswerRe: Not telling me where the error is Pin
Ivan Krivyakov4-Jan-12 8:19
memberIvan Krivyakov4-Jan-12 8:19 
GeneralRe: Not telling me where the error is Pin
Member 85397564-Jan-12 8:47
memberMember 85397564-Jan-12 8:47 
GeneralMy vote of 4 Pin
JV99999-Jun-11 1:20
memberJV99999-Jun-11 1:20 
GeneralSounds promising! Pin
JV99998-Jun-11 10:16
memberJV99998-Jun-11 10: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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.171019.1 | Last Updated 8 Jun 2011
Article Copyright 2011 by Ivan Krivyakov
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid