I\'ve got this application that works locally and when deployed and using a .mdf SQL Express database file (which I usually use for testing purposes). However, when I change
A database connection from a hosted WCF Service is considered a remote connection so make sure your connection strings specifies the authentication method. So try using Integrated Security=SSPI in your connection string and if that doesn't work make sure that your Application Pool's Identity is set to a domain account that has permissions on the SQL server. :)
This could be that you are making a POST but the service is expecting a GET.
Try specifying that the method should be a POST:
[WebInvoke(Method = "POST", UriTemplate = "", ResponseFormat = WebMessageFormat.Json)]
The other this that it could be is that you are using a trusted connection. This means that the security context is the identity of the application pool (if defaults are used). Then you will be making a connection to the database using a local account that does not have access on a database on a different machine.
The strange thing is that based on the error message it should be the first explaination, but based on your description it would be the second.
You're probably not setting HTTP headers exactly as the service is expecting them, or in the order it's expecting them.
Here's how I'd debug it: