I am net to the use of WCF. I have been struggling with the construct of writing to a database using WCF after deployment. I connect to the WCF via a android Application.
The basic construct that I use is that i implement the WCF with database and attempt to ping the WCF that is deployed on a server by entering the IP and the path.
In my WCF I have two functions. One function Returns the Date and the other function writes to a database using LINQ. When I run the function that must return the date in my browser on android via http://10.0.0.14/jonts/WCFService.svc/date
I get a response with no problem. The problem comes up when I run the function to write to the database via http://10.0.0.14/jonts/WCFService.svc/write
, I get a 400 Error. But when i run http://localhost:58632/WCFService.svc/write
from the host machine it write to the database.
I believe that this is cause by the connection string in my .confic file.
<?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>
The server with IP 10.0.0.14 is running SQL Server Developer 2012.
1)Is it my connection string causing this error?
2)How can I fix this?