Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I've created a WCF WebService which connects to the Taxonomy service from SharePoint with a 'Service Reference' in Visual Studio 2010 to the https://localhost/sites/MYSITE/_vti_bin/TaxonomyClientService.asmx service.

But when calling the method GetTermSets(...) I do sometimes get this exception:

System.ServiceModel.ProtocolException: The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 52 bytes of the response were: 'No credentials are available in the security package'.

Server stack trace: 
   at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Any idea why this happens ?

share|improve this question
add comment

1 Answer 1

It seems that when I switched to the old 2.0 .NET compatible 'Web Reference', the problem was solved.

public partial class Taxonomywebservice
{
  public Taxonomywebservice(BusinessConfig config) : base()
  {
    base.Url = config.Taxonomy;
    base.Credentials = new NetworkCredential(config.UserName, config.Password, config.Domain);
    base.PreAuthenticate = true;
  }
}

I don't have a good explanation for this, maybe the PreAuthenticate = true solves the issue ?

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.