WCF Web服务在SharePoint 2010浏览器空白页面响应中托管

时间:2013-07-11 09:56:00

标签: wcf rest sharepoint-2010 web-config

我正面临SharePoint 2010自定义Web服务的问题。 该服务是在系统上安装和部署的SVC:没有特殊配置它可以工作,但我需要自定义web.config以实现一些安全角色。

问题在于,当我尝试从浏览器调用方法时,响应为空。

这是我的web.config

<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="SharePointWCFService.GetListData" 
behaviorConfiguration="WCFBasicHttpBinding.Service1Behavior">
<endpoint address="http://address" binding="basicHttpBinding" contract="SharePointWCFService.IGetListData">
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/> 
<endpoint address="http://address" binding="WebHttpBinding" contract="SharePointWCFService.IGetListData" >
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
</service>
 </services>
 <behaviors>
 <serviceBehaviors>
 <behavior name="WCFBasicHttpBinding.Service1Behavior">
<serviceMetadata httpGetEnabled="true"/>

<serviceDebug includeExceptionDetailInFaults="true"/>
 </behavior>
 </serviceBehaviors>
 </behaviors>
 </system.serviceModel> 
 </configuration>

这是我正在实施的界面:

[ServiceContract]
 public interface IGetListData
 {
   [OperationContract]
   [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
   JSonResult GetJsonResponse(string data);

}

这就是班级

[BasicHttpBindingServiceMetadataExchangeEndpointAttribute]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Required)]
class GetListData : IGetListData
{
    private const string Admin_Svc_GetListData = "Admin_Svc_GetListData";

    public JSonResult GetJsonResponse(string data)
    {
        return new JSonResult()
        {
            Firstname = "MyFirstname",
            Lastname = "MyLastname"
        };
    } //  public JSonResult GetJsonResponse(string data)

我必须在web.config端声明一些不同的东西吗?

0 个答案:

没有答案