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:
- AddTerms
- GetChildTermsInTerm
- GetChildTermsInTermSet
- GetKeywordTermsByGuids
- GetTermSets
- GetTermsByLabel
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):
disco.exe http://example.com/_layouts/test/TaxonomyClientService.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.
I have SP1, and those definitions exist.
ReplyDeleteThank you! You've saved my brain!
ReplyDeleteHi, Alex. If I understand correctly, in SP1 this issue still doesn't fixed, does it?. I've done the same actions, and got the identical TaxonomyClientServicewsdl.aspx file. After that GetChildTermsInTermSet method works well, but GetChildTermsInTerm method does not. It always throws exception like "Server was unable to process request. ---> Object reference not set to an instance of an object." Have you ever tried to use this method?
ReplyDeleteSergey,
ReplyDeleteI didn't check it in SP1 by myself - may be it still exists (Nuno commented above that it still exists). This problem was investigated for my colleague - he said that it worked.
I know this is an older post, but I am now having this issue. I have updated the wsdl file, but still not seeing the GetChildTerms... Do I have to update the TaxonomyClientService.asmx or a .dll too? I think I am missing something obvious, but not sure what.
ReplyDeleteCraig,
ReplyDeleteas far as I remember neither asmx nor dll should be updated. Try to create new project in VS and add new service reference there. May be there is something wrong with updating service reference in VS.
Well apparently you have to update the web server, not the application server. It works a lot better once you do the right thing. :)
ReplyDeleteThanks!!!
Craig
great, that you figured it out)
ReplyDeleteSome of the time the logo configuration firms charges additional for any extra charges. Look at the hourly rates, print rates, stock photography, refreshes, web facilitating and all other required subtleties before focusing on any corporate logo configuration administration. logo design service
ReplyDelete