簡體   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