Sharepoint 2010中WCF服务存在的问题

3
我需要为SharePoint 2010创建WCF服务。使用Jquery ajax与此服务通信的想法。但是所有调用服务方法的尝试都失败了。
我尝试使用 WCF测试客户端,并获得以下消息:
Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service.

错误详情如下:

    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 227 bytes of the response were: 'A transport-level error has occurred when sending the request to the server. (provider: Shared Memory Provider, error: 0 - Either a required impersonation level was not provided, or the provided impersonation level is invalid.)'.

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.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at ITV2WCFService.DoWork()
   at TV2WCFServiceClient.DoWork()

输入图像描述

但是服务http://localhost/_vti_bin/site/TEMPSERVICE.svc/mex可用并且给我正常的响应。

一切都按照MSDN上的文章完成了。

http://msdn.microsoft.com/en-us/library/ff521581.aspx

问题在哪里以及如何处理?


1
你能否使用浏览器、Fiddler或测试应用程序正常访问WCF服务?使用Fiddler检查来回流量。检查报头、内容等。也许你正在发送JSON,但期望的是text/XML格式? - Dustin Davis
没有,我根本没有任何属性。只是新创建的服务。 - Ievgen
2个回答

1

Evgeny:

看起来你的 Web 服务返回标准的 SOAP XML 响应。JQuery 希望使用 JSON。我认为更简单的方法是将 JQuery 设置为使用 XML。或者,你可以更改你的 Web 服务,使其返回 JSON 而不是 XML。


不行,因为WCF测试客户端也失败了。问题出在IIS配置上,需要启用匿名访问权限。 - Ievgen

1
解决方案:必须启用匿名访问!

我不得不在站点级别启用匿名访问,我试图只在托管svc文件的文件夹中启用它,但没有成功。 - Nimesh Madhavan

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接