locked
TaxonomyClientService returns empty resultset for site collection termset RRS feed

  • Question

  • We have an issue where a 3rd party tool uses TaxonomyClientService.asmx GetTermSets to retrieve a list of terms to display in a form.  In both a test and production environment, we've found that it does not work for site-collection-level termsets.  It does work for farm-level termsets.  Looking at the traffic with fiddler, we see that the service is returning an empty termset. ie:

    <Container></Container>

     From what I can tell, the parameters being passed to the service look fine.  I can take the same guids and use them to pull the termset using powershell, and see terms in it.

    What would cause this to happen?   What are we missing here?

    Sunday, October 16, 2011 12:21 AM

Answers

  • Hi Danroot,

    This sounds very farmiliar to me..

    When you are trying to consume the service you should pinpoint to the exact site location when building your WCF connection. This is not required for the farm level term sets. So when your term set is defined in a site collection you should point your web part (page or other consumer) to the root of the site collection and build your WFC connection from there dynamic instead of putting the url of your end-point into a web.config.

    Pretty sure this is the problem. Mostly because your calls are not returning an error just an empty result set, which is correct behaviour :-)

    The code below should help you out, just set a service reference to the TaxonomyClientService.asmx name it TaxonomyClientService

    private static TaxonomyClientService.TaxonomywebserviceSoapClient CreateProxy(string siteUrl)
            {
                BasicHttpBinding basicHttpBinding = default(BasicHttpBinding);
                TaxonomyClientService.TaxonomywebserviceSoapClient proxy = null;
                //AxtentionsEcm.SiteSearchSoapClient ecmSearchProxy = null;
                try
                {
                    basicHttpBinding = GetBasicHttpBinding();
    
                    //Het endpoint word opgezet richting de sub site waarin gezocht moet worden
                    EndpointAddress endpoint = new EndpointAddress(siteUrl + "/_vti_bin/TaxonomyClientService.asmx");
                    proxy = new TaxonomyClientService.TaxonomywebserviceSoapClient(basicHttpBinding, endpoint);
    
                    //We gaan onder impersonation en de huidige networkcredentials naar de sharepoint service.
                    proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                    proxy.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("TaxonomyViewer", "private static TaxonomyClientService.TaxonomywebserviceSoapClient CreateProxy(string siteUrlXml) " + ex.Message + ex.StackTrace);
                }
                return proxy;
            }
    
            private static BasicHttpBinding GetBasicHttpBinding()
            {
                BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
                try
                {
                    basicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                    basicHttpBinding.MaxBufferSize = 2097152;
                    basicHttpBinding.MaxBufferPoolSize = 2097152;
                    basicHttpBinding.MaxReceivedMessageSize = 2097152;
                    basicHttpBinding.ReaderQuotas.MaxStringContentLength = 65536;
                    //Security can be set to Windows. Ntlm, None, Digest, Certificate or Basic
                    basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("TaxonomyViewer","private static BasicHttpBinding GetBasicHttpBinding()" + ex.Message + ex.StackTrace);
                    throw;
                }
                return basicHttpBinding;
            }
    At least that is what the 3d party tool should be doing.. :-)

    Sunday, October 16, 2011 7:45 AM

All replies

  • Hi Danroot,

    This sounds very farmiliar to me..

    When you are trying to consume the service you should pinpoint to the exact site location when building your WCF connection. This is not required for the farm level term sets. So when your term set is defined in a site collection you should point your web part (page or other consumer) to the root of the site collection and build your WFC connection from there dynamic instead of putting the url of your end-point into a web.config.

    Pretty sure this is the problem. Mostly because your calls are not returning an error just an empty result set, which is correct behaviour :-)

    The code below should help you out, just set a service reference to the TaxonomyClientService.asmx name it TaxonomyClientService

    private static TaxonomyClientService.TaxonomywebserviceSoapClient CreateProxy(string siteUrl)
            {
                BasicHttpBinding basicHttpBinding = default(BasicHttpBinding);
                TaxonomyClientService.TaxonomywebserviceSoapClient proxy = null;
                //AxtentionsEcm.SiteSearchSoapClient ecmSearchProxy = null;
                try
                {
                    basicHttpBinding = GetBasicHttpBinding();
    
                    //Het endpoint word opgezet richting de sub site waarin gezocht moet worden
                    EndpointAddress endpoint = new EndpointAddress(siteUrl + "/_vti_bin/TaxonomyClientService.asmx");
                    proxy = new TaxonomyClientService.TaxonomywebserviceSoapClient(basicHttpBinding, endpoint);
    
                    //We gaan onder impersonation en de huidige networkcredentials naar de sharepoint service.
                    proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
                    proxy.ChannelFactory.Credentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("TaxonomyViewer", "private static TaxonomyClientService.TaxonomywebserviceSoapClient CreateProxy(string siteUrlXml) " + ex.Message + ex.StackTrace);
                }
                return proxy;
            }
    
            private static BasicHttpBinding GetBasicHttpBinding()
            {
                BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
                try
                {
                    basicHttpBinding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                    basicHttpBinding.MaxBufferSize = 2097152;
                    basicHttpBinding.MaxBufferPoolSize = 2097152;
                    basicHttpBinding.MaxReceivedMessageSize = 2097152;
                    basicHttpBinding.ReaderQuotas.MaxStringContentLength = 65536;
                    //Security can be set to Windows. Ntlm, None, Digest, Certificate or Basic
                    basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.EventLog.WriteEntry("TaxonomyViewer","private static BasicHttpBinding GetBasicHttpBinding()" + ex.Message + ex.StackTrace);
                    throw;
                }
                return basicHttpBinding;
            }
    At least that is what the 3d party tool should be doing.. :-)

    Sunday, October 16, 2011 7:45 AM
  • Hi danroot,

    In addition to Rainier Van Slingerlandt's response, if you meant "site collection level" termset as a local termset, then it should not be got by the web service by design.

    You can see the following thread for more information:
    http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/4d53d145-476a-4f98-9bf0-9bc4cdbad138/

    Thanks,
    Jinchun Chen


    Jinchun Chen
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff AT microsoft.com(Please replace AT with @)
    Monday, October 17, 2011 1:40 AM
  • Rainer is right.  If I call the webservice from beneath the site collection url, it works. 
    Monday, October 17, 2011 7:09 PM