【发布时间】:2014-07-14 17:44:51
【问题描述】:
我对 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="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\SampleDb.mdf;Integrated Security=True;User Instance=True;MultipleActiveResultSets=True""
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?
【问题讨论】:
标签: c# database wcf iis connection-string