Already struggling with the poor functionality of the web service interface of the Taxonomy web service of SharePoint 2010, I stumbled upon another challenge.
I was building a MS CRM 2011 Plugin that populates the SharePoint Term Store using the Taxonomy web service (http://<sharepointurl>/_vti_bin/TaxonomyClientService.asmx).
The first problem was the poor functionality of the web service like being unable to add Labels to Terms.
This cannot be fixed worked around.
Then I had to query SharePoint for a Term that contained an ampersand.
Adding the Term was not a problem when the XML was escaped properly.
string _newterm = “V&D”;
_newterm = _newterm.Replace(“&”, “&”).Replace(“<“, “<”).Replace(“>”, “>”).Replace(“\””, “"”).Replace(“‘”, “'”);
But when the SharePoint is queried for a certain Term… it works slightly different.
The TermStore can be queried for example using “GetTermsByLable()”
string TermXml = SPTaxService.GetTermsByLabel(TermLabel,
When you send use the TaxonomyClientService.asmx, the service will not find your term, even though when you created it you used the exact same string.
The reason is that an & will be stored by SharePoint as \uFF06
So when you wanna search for a Term, make sure you replace the ampersand… like…
string XmlTerm = “<newTerms><newTerm label=\”” + _newterm.Replace(“&”, “\uFF06”) + “\” clientId=\”1\” parentTermId=\”” + Guid.Empty + “\”></newTerm></newTerms>”);
The weird thing is, that the VS2010 Debugger still will show you the &
The result from SharePoint is the right one…
So …replacing the & with & does not work..!