Monday, October 13, 2008

How to validate your WSDL

@YaronNaveh

Update: WsiHero is A GUI utility to validate Wsdl / Soap using the latest WSI profile.

Your service WSDL file is the contract between you and your web service clients. Whether you manually write the WSDL or let your framework automatically generate it for you - you want to make sure it is valid (otherwise you'l have no clients!).

There is more than one way to define the validity of a WSDL: Does it need to be valid according the WSDL XML schema? Does it need to comply to known best practices? Does it need to be parsed correctly by common soap stacks? There are different ways to test each of these requirements. Commercial tools, like XMLSpy, can help you with some. Today I'll show you a free alternative: the WSI test tool. WSI is the web services interoperability organization and it has defined the WSDL "basic profile" - a set of best practice recommendations for WSDLs. They have also published a tool that can tell you if your WSDL confirms to this profile and today I'll show you how to use it.

Update: WsiHero is A GUI utility to validate Wsdl / Soap using the latest WSI profile.

Step 1 - Download the WSI test tool
Go to the downloads page in the WSI site and download "Interoperability Testing Tools 1.1". It has a C# and a Java version - today we will use the C# one but using the Java is similar.

Step 2 - Extract the tool
Just extract the zip to some folder

Step 3 - Configure the test
Copy wsi-test-tools\cs\samples\analyzerConfig.xml to wsi-test-tools\cs\bin and open it with a text editor. Change the following values:

  • wsdlURI - Should contain the url for your wsdl, for example http://MyServer/MyService.asmx?WSDL
  • serviceLocation - Should contain the url for your service, for example http://MyServer/MyService.asmx
  • wsdlElement - This is the most confusing one. Your service has at least one endpoint/port. Here you need to define which one you currently want to test. In order to supply this data open your WSDL in internet explorer and notice that its structure is something like:


    <wsdl:definitions ...targetNamespace="http://tempuri.org/" ...
    <!--a lot of tags-->
    <wsdl:binding name="MyServiceSoap"...
    <!--a lot of tags-->


    So take the value of the "targetNamespace" from here and put its value in the "namespace" attribute of the "wsdlElement" element in the configuration. Also take the value of the "name" element and put it in the "wsdlElement" element value. So the "wsdlElement" configuration may look like:


    <wsdlElement type="binding" namespace="http://tempuri.org/">MyServiceSoap</wsdlElement>


    Note: If you have a few "wsdl:Binding" in your wsdl you should repeat this for each one.

    Step 4 - Run the test
    Open command line and go to the wsi-test-tools\cs\bin directory. Then run:


    $> Analyzer


    Step 5 - Analyze the results
    The wsi-test-tools\cs\bin folder now contains a file report.xml. Open it in internet explorer to view the results.





    Update: WsiHero is A GUI utility to validate Wsdl / Soap using the latest WSI profile.

    @YaronNaveh

    What's next? get this blog rss updates or register for mail updates!
  • 0 comments: