Recently I found interesting problem when work with TaxonomyClientService.asmx. This service can be used by client applications in order to work with Sharepoint managed metadata. As msdn says:
This Web service enables a client to interact with the managed metadata TermStore object and get the data through label matching, per Microsoft.SharePoint.Taxonomy.TermSet, or by GUID. Updates to the TermStore can also be made by adding a new Term object.
As many other OTB Sharepoint web services, TaxonomyClientService.asmx file is located in 14/ISAPI folder and is accessible by the following URL: http://example.com/_vti_bin/TaxonomyClientService.asmx (where http://example.com part belongs to some Sharepoint web site). When you enter this URL you will see the following web methods:
In order to use this web service we should perform usual steps: add service reference (or web reference) and use generated proxy. And here we got the problem: in generated proxy class all web methods exist except GetChildTermsInTerm and GetChildTermsInTermSet:
This was strange. The first thing I made is checked TaxonomyClientService class in Reflector to ensure that mentioned methods contains [WebMethod] attribute. They had it:
Then I checked wsdl of the TaxonomyClientService.asmx (added ?wsdl to the web service url) – and it didn’t contain the definition of the GetChildTermsInTerm and GetChildTermsInTermSet methods. So that was the problem.
As you probably know in Sharepoint wsd land disco files are located near asmx file in format *wsdl.aspx and *disco.aspx. So I checked TaxonomyClientServicewsdl.aspx – and, as I expected, definitions of GetChildTermsInTerm and GetChildTermsInTermSet methods were missing here. For me this looks like a bug.
Visual Studio uses these *wsdl.aspx files in order to generate web service proxy. Also IE uses it when you click on Service Description link on the web service page. Try to rename TaxonomyClientServicewsdl.aspx to TaxonomyClientServicewsdl.aspx_ (with leading underscore) and you will see that neither VS nor IE can show wsdl anymore. Rename it back and they will work again.
Ok, we know the reason, but what we should do before we will get official patch from MS? We need to fix it by ourselves. That’s how you can do it:
- Backup original wsdl file TaxonomyClientServicewsdl.aspx to TaxonomyClientServicewsdl.aspx_orig
- Copy TaxonomyClientService.asmx to 14/Template/Layouts/Test (but don’t copy *wsdl.aspx and *disco.aspx files). Doing by this you will get wsdl file generated dynamically based on actual asmx web methods.
- Use disco.exe tool from MS SDK in order to generate the correct wsdl of the web service using the new URL (or just open the following URL in browser http://example.com/_layouts/test/TaxonomyClientService.asmx?asmx):
- It will generate 2 files: TaxonomyClientService.disco and TaxonomyClientService.wsdl
- Check that newly generated wsdl file contains definitions of GetChildTermsInTerm and GetChildTermsInTermSet methods
- Now we need compare original TaxonomyClientServicewsdl.aspx and generated TaxonomyClientService.wsdl file and copy missing parts from newly generated file into original file. Note, that you should not just replace original file with new one because it has additional code for adopting it for Sharepoint (Page directive and SPEncode.WriteHtmlEncodeWithQuote()). I used Beyond compare tool and just copy parts of code from wsdl file to TaxonomyClientServicewsdl.aspx which are related with missing methods.
After you will save changes in TaxonomyClientServicewsdl.aspx you should update reference in your VS project – and after that you will be able to use GetChildTermsInTerm and GetChildTermsInTermSet methods in the code:
I uploaded fixed version of TaxonomyClientServicewsdl.aspx file here.
Recently SP1 was released for Sharepoint 2010 however I don’t have it now to check whether or not this bug was fixed there. Will update this post as far as I will check it.