开发者

Sharepoint 2010 problems with WCF service

开发者 https://www.devze.com 2023-02-12 17:28 出处:网络
I need to create wcf service for sharepoint 2010. The idea to use Jquery ajax to communicate with this service. But all cals to service methods always fail.

I need to create wcf service for sharepoint 2010. The idea to use Jquery ajax to communicate with this service. But all cals to service methods always fail. The

I try to use WCF Test Client and get message:

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.

and error detais:

    The content type text/html; charset=utf-8 of the response message do开发者_运维问答es 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()

Sharepoint 2010 problems with WCF service

But service http://localhost/_vti_bin/site/TEMPSERVICE.svc/mex is avaliable and give me normal response.

Everything done according to article on msdn

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

Whats the problem and how to deal with it?


Evgeny:

It looks like your webservice returns standard SOAP XML response. JQuery expects to use JSON. I think the easier way is to set JQuery to use XML. Alternatively you can change your web service to return JSON instead of XML.


Solution: Anonymous access have to be enabled!

0

精彩评论

暂无评论...
验证码 换一张
取 消