在sharepoint上托管Web服务? [英] Hosting a webservice on sharepoint?

查看:68
本文介绍了在sharepoint上托管Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对与在SharePoint中托管wcf有关的问题感到困惑.我无法访问我的Web服务,我在SharePoint网站上看​​到它,但是当我单击它时,我收到一条错误消息

因此,我有了名为以下内​​容的ASP.NET Web应用程序:Foo.PS2016.PSIExtension

借助其iservice和Service(非常简单的一种):

服务:

   命名空间Foo.PS2016.PSIExtension
    {
       [ServiceContract]
       IService接口
       {
           [OperationContract]
           bool isAlive();
       }
    }

服务:

   命名空间Foo.PS2016.PSIExtension
       {
    
      [AspNetCompatibilityRequirements(RequirementsMode =    AspNetCompatibilityRequirementsMode.Allowed)]
     内部类服务:IService
     {
      公共布尔isAlive()
          {
           return(true);
          }
       }
    }

其Service.svc:

**<%@ ServiceHost语言="C#" Debug ="true"服务="Foo.PS2016.PSIExtension.Service" %> **

及其网络服务:

    *<?xml version ="1.0" encoding ="utf-8"?>
    <!-
     ->
    < configuration>
     < appSettings>
       <添加密钥="aspnet:UseTaskFriendlySynchronizationContext";值=真" />
     </appSettings>
     < system.web>
       < compilation debug ="true"; targetFramework ="4.5.2"/>
       < httpRuntime targetFramework ="4.5.2"/>
       < httpModules>
         < add name ="ApplicationInsightsWebTracking"; type ="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule,Microsoft.AI.Web"/>
       </httpModules>
     </system.web>
     < system.serviceModel>
       <行为>
         < serviceBehaviors>
           <行为>
            <!-为避免泄露元数据信息,请在部署之前将以下值设置为false->
            < serviceMetadata httpGetEnabled ="true"; httpsGetEnabled ="true"/>
            <!-要在故障中接收异常详细信息以进行调试,请将下面的值设置为true.部署前设置为false以避免泄露异常信息 ->
            < serviceDebug includeExceptionDetailInFaults ="true"/>
           </行为>
         </serviceBehaviors>
       </行为>
       < protocolMapping>
         < add binding ="basicHttpsBinding" scheme ="https" />
       </protocolMapping>
       < serviceHostingEnvironment aspNetCompatibilityEnabled ="true"; multipleSiteBindingsEnabled ="true"; />
     </system.serviceModel>
     < system.webServer>
       < modules runAllManagedModulesForAllRequests ="true"/>
       <!-
          要在调试期间浏览Web应用程序的根目录,请将下面的值设置为true.
          部署前设置为false,以避免泄露Web应用程序文件夹信息.
         ->
       < directoryBrowse enabled ="true"/>
     </system.webServer>
    </configuration> *

并且我的SharePoint解决方案的文件夹为ISAPI => PSI => Foo.PS2016.PSIExtension.svc  :

<%@ ServiceHost language =" c#"服务="Foo.PS2016.PSIExtension.Service,Foo.PSI2016.PSIExtension,版本= 1.0.0.0,文化=中性,PublicKeyToken = 9bca1c0679b0bdc1". %>

版本,区域性和公钥来自文件的Powershell命令:Foo.PS2016.PSIExtension.dll

所以从今天早上开始我就一直坚持这个问题,所以如果有人有什么想法可以帮助我






I'm loosing my mind with an issue about hosting wcf in SharePoint. I'm not able to reach my webservice, I saw on it on my SharePoint site but when I'm clicking on it I have an error message

So i have my ASP.NET Web Application which is called: Foo.PS2016.PSIExtension

With its iservice and Service (Very simple one):

Iservice:

    namespace Foo.PS2016.PSIExtension
    {
        [ServiceContract]
        interface IService
        {
            [OperationContract]
            bool isAlive();
        }
    }

Service:

    namespace Foo.PS2016.PSIExtension
        {
    
       [AspNetCompatibilityRequirements(RequirementsMode =     AspNetCompatibilityRequirementsMode.Allowed)]
       internal class Service : IService
      {
        public bool isAlive()
           {
            return (true);
           }
        }
    }

its Service.svc:

**<%@ ServiceHost Language="C#" Debug="true" Service="Foo.PS2016.PSIExtension.Service"  %>**

and its webservice:

    *<?xml version="1.0" encoding="utf-8"?>
    <!--
      -->
    <configuration>
      <appSettings>
        <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
      </appSettings>
      <system.web>
        <compilation debug="true" targetFramework="4.5.2"/>
        <httpRuntime targetFramework="4.5.2"/>
        <httpModules>
          <add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
        </httpModules>
      </system.web>
      <system.serviceModel>
        <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="true"/>
            </behavior>
          </serviceBehaviors>
        </behaviors>
        <protocolMapping>
          <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
      </system.serviceModel>
      <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
            To browse web app root directory during debugging, set the value below to true.
            Set to false before deployment to avoid disclosing web app folder information.
          -->
        <directoryBrowse enabled="true"/>
      </system.webServer>
    </configuration>*

and I have my SharePoint solution with its folder ISAPI=>PSI=>Foo.PS2016.PSIExtension.svc  :

<%@ServiceHost language="c#" Service="Foo.PS2016.PSIExtension.Service, Foo.PSI2016.PSIExtension, Version=1.0.0.0, Culture=neutral, PublicKeyToken=9bca1c0679b0bdc1" %>

The Version, culture and PublicKey comes from a powershell command from the file: Foo.PS2016.PSIExtension.dll

So I have been stucking on this issue since this morning so if someone has some ideas to help me






推荐答案

 我建议您将wcf转换为其余的wcf,通过这种方式,您将易于部署,并且无需编辑web.config即可为新创建的wcf添加任何终结点

 i advise you to convert your wcf to rest wcf , by this way you will get easy deployment and you won't need to edit the web.config for adding any endpoint for the new created wcf

将您的wcf更改为休息"

for changing your wcf to rest 

1-打开.wcf,将工厂值更改为以下内容,并将service和codebahind属性值更改为您的项目值.

1- open .wcf , change the factory value as the following , and change service and codebahind properties values to your project values.

<%@ ServiceHost Language="C#" Debug="true"
    Service="MyProject.PortalService.DashboardStatisticsService,


SharePoint.Project.AssemblyFullName
SharePoint.Project.AssemblyFullName


" CodeBehind ="DashboardService.svc.cs" Factory ="Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime,版本= 15.0.0.0,文化=中性, PublicKeyToken = 71e9bce111e9429c"; %>
" CodeBehind="DashboardService.svc.cs" Factory="Microsoft.SharePoint.Client.Services.MultipleBaseAddressWebServiceHostFactory, Microsoft.SharePoint.Client.ServerRuntime, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

2-打开界面",我添加了Web调用属性

2- open the Interface , i added web invoke properties 

namespace Foo.PS2016.PSIExtension
    {
        [ServiceContract]
        interface IService
        {
            [OperationContract]
[WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Bare, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
            bool isAlive();
        }
    }

3-请查看以下在SharePoint中托管的非常详细的自定义WCF REST服务

3- have a look on the following very detailed Custom WCF REST Service Hosted in SharePoint


这篇关于在sharepoint上托管Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆