繁体   English   中英

将具有数据库功能的WCF服务部署到IIS

[英]Deploying WCF Service with Database Functionality to IIS

我对使用WCF感到很满意。 部署后,我一直在努力使用WCF写入数据库的构造。 我通过Android应用程序连接到WCF。

我使用的基本结构是使用数据库实现WCF,并尝试通过输入IP和路径来ping通部署在服务器上的WCF。

在我的WCF中,我有两个功能。 一个函数返回日期,而另一个函数使用LINQ写入数据库。 当我运行必须通过http://10.0.0.14/jonts/WCFService.svc/date在Android上的浏览器中返回日期的函数时,我得到的响应没有问题。 当我运行该函数以通过http://10.0.0.14/jonts/WCFService.svc/write写入数据库时​​,出现问题,出现400错误。 但是,当我从主机运行http://localhost:58632/WCFService.svc/write ,它将写入数据库。

我相信这是由我的.confic文件中的连接字符串引起的。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
  </system.web>
  <system.serviceModel>
   <services>
      <service name="WCF_Connection.WCFService">
        <endpoint address="" behaviorConfiguration="restfulBehavior"
      binding="webHttpBinding" bindingConfiguration="" contract="WCF_Connection.IWCFService" />
        <host>
          <baseAddresses>
            <add baseAddress="http://10.0.0.14/bookservice" />
          </baseAddresses>
        </host>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="restfulBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>
  <connectionStrings>
    <add name="SampleDbEntities" connectionString="metadata=res://*/BooksModel.csdl|res://*/BooksModel.ssdl|res://*/BooksModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SampleDb.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True&quot;"
  providerName="System.Data.EntityClient" />
    <add name="jarvisConnectionString" connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\jarvis.mdf;Integrated Security=True"
  providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>

IP 10.0.0.14的服务器正在运行SQL Server Developer 2012。

1)Is it my connection string causing this error?
2)How can I fix this?

1)您在连接字符串中使用“集成安全性”选项,因此您应检查在为wcf应用程序提供服务的IIS中,AppPool是否在有权连接数据库和执行查询的Windows用户下运行。 或考虑使用登录名/密码指定sql server登录(在这种情况下,应使用混合安全模式安装SQL Server)。

2)使用跟踪来确定服务器上的实际WCF错误。 或改变

<serviceDebug includeExceptionDetailInFaults="false" />

<serviceDebug includeExceptionDetailInFaults="true" />

在调试应用程序时。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM