主机WCF服务,500 System.ServiceModel.ServiceActivationException

时间:2016-02-14 22:44:12

标签: c# wcf iis sharepoint

我尝试使用Sharepoint 2013基础在Windows服务器2012中托管WCF服务。

在我的服务上,我有这个界面。

[ServiceContract(Namespace = "")]
public interface ISharePointGappService
{

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spGetAllUserResponse spGetAllUser();

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spGetAllUserResponse spGetUsers(spGetAllUserRequest request);

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spListFilesResponse spListFiles(spListFilesRequest request);

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spCreateUserResponse spCreateUser(spCreateUserRequest request);

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spGetUserResponse spGetUser(spGetUserRequest request);

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spDeleteUserResponse spDeleteUser(spDeleteUserRequest request);

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spSearchFilesResponse spSearchFiles(spSearchFilesRequest request);

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spDownloadFilesResponse spDownloadFiles(spDownloadFilesRequest request);

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spGetFileResponse spGetFile(spGetFileRequest request);

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spCreateFolderResponse spCreateFolder(spCreateFolderRequest request);

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spDeleteFolderResponse spDeleteFolder(spDeleteFolderRequest request);

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spUploadFileResponse spUploadFile(spUploadFileRequest request);

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spDeleteFilesResponse spDeleteFiles(spDeleteFilesRequest request);

    [OperationContract]
    [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json)]
    spShareFileResponse spShareFile(spShareFileRequest request);


}

我的web.config就是这个

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    ...
  </appSettings>
  <system.web>
    <compilation debug="true" />
  </system.web>
  <!-- When deploying the service library project, the content of the config file must be added to the host's 
  app.config file. System.Configuration does not support config files for libraries. -->
  <system.serviceModel>
    <services>
      <service name="Mobilu.SharePoint2013Gapp.Services.SharePointGappService" >
        <host>
          <baseAddresses>
            <add baseAddress="http://win-ricm5vnko1f/" />
          </baseAddresses>
        </host>
        <!-- Service Endpoints -->
        <!-- Unless fully qualified, address is relative to base address supplied above -->
        <endpoint address="" binding="webHttpBinding" behaviorConfiguration="web" contract="Mobilu.SharePoint2013Gapp.Services.ServiceContract.ISharePointGappService">
          <!-- 
              Upon deployment, the following identity element should be removed or replaced to reflect the 
              identity under which the deployed service runs.  If removed, WCF will infer an appropriate identity 
              automatically.
          -->
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <!-- Metadata Endpoints -->
        <!-- The Metadata Exchange endpoint is used by the service to describe itself to clients. -->
        <!-- This endpoint does not use a secure binding and should be secured or removed before deployment -->
        <!--<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />-->
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, 
          set the values below to false before deployment -->
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
          <!-- To receive exception details in faults for debugging purposes, 
          set the value below to true.  Set to false before deployment 
          to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

当我在Visual Studio上运行我的项目时,我会看到这个窗口 enter image description here

如果使用WCF测试客户端或Postman调用他们正常工作的方法,当我停止visual studio调试时,调用显然停止工作,我想在我的sharepoint上托管这个并且能够调用方法。

当我发布我的项目时,我得到:

  

Mobilu.SharePoint2013Gapp.Services.SharePointGappService.svc

     

web.config

     

bin文件夹

然后我试着把它放在这里: enter image description here 当我调用相同的方法(POST)我在visual studio调试时做了,我得到了这个错误

  

500 System.ServiceModel.ServiceActivationException

如果我尝试直接使用浏览器访问该文件,我会得到一个包含此

的页面

&#34;类型&#39; Mobilu.SharePoint2013Gapp.Services.SharePointGappService&#39;,作为ServiceHost指令中的Service属性值提供,或者在配置元素system.serviceModel / serviceHostingEnvironment / serviceActivations中提供被发现。 &#34;

0 个答案:

没有答案