Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
访问SQL Server数据库的Rest WCF_Wcf_Rest - Fatal编程技术网

访问SQL Server数据库的Rest WCF

访问SQL Server数据库的Rest WCF,wcf,rest,Wcf,Rest,我有一个访问SQL Server数据库的RESTful WCF服务。当它在IIS Express上运行时,我可以使用它访问数据库,但当它在本地IIS上运行时,它不会从数据库返回任何内容 以下是合同中的方法: [OperationContract] [WebGet(UriTemplate = "/getdata", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json, R

我有一个访问SQL Server数据库的RESTful WCF服务。当它在IIS Express上运行时,我可以使用它访问数据库,但当它在本地IIS上运行时,它不会从数据库返回任何内容

以下是合同中的方法:

[OperationContract]
[WebGet(UriTemplate = "/getdata",
 BodyStyle = WebMessageBodyStyle.WrappedRequest,
 ResponseFormat = WebMessageFormat.Json,
 RequestFormat = WebMessageFormat.Json)]
List<DbData> getData();

当我在IIS Express上运行此WCF服务时,它会从数据库返回数据,但当我在本地IIS上托管它并运行它时,它不会从数据库返回数据,它只显示带[]的空页面

您可能需要检查应用程序池的用户ID。检查应用程序池用户id是否有权连接到SQL server。将应用程序池id添加到sql server或更改连接字符串以使用sql身份验证。i、 e.在sql server中创建的用户的连接字符串中使用用户id和密码

这里有更多的帮助


请分享您认为给您带来麻烦的代码部分。请说明哪里出了问题。我编辑了这篇文章,我希望现在已经清楚了!从何处获取我的应用程序池@theusguy?的用户id?thanx,在sql server中创建的用户的连接字符串中添加用户id和密码,您节省了我的时间
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <connectionStrings>
      <add name="AlamalConStr" 
           connectionString="Data Source=.;  Initial Catalog=trial_web_service_db;Integrated Security=True" 
           providerName="System.Data.SqlClient" />
   </connectionStrings>
   <appSettings>
       <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
   </appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Windows" />
<identity impersonate="false" />
</system.web>
<system.serviceModel>
   <services>
       <service name="AlamalBankWCFService.AlamalService">
           <endpoint kind="webHttpEndpoint" contract="ServiceLib.IAlamalService">
              <identity>
                 <dns value="localhost"/>
              </identity>
           </endpoint>
       </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior>
               <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
               <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="wsHttpBinding" scheme="https" />
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
                               multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
   <modules runAllManagedModulesForAllRequests="true" />
   <directoryBrowse enabled="true" />
</system.webServer>
</configuration>