I'm writing a WCF service in Visual Studio 2008 to be hosted on a Windows 2008 Standard server.
I've created a new Web Site in IIS7 with its own application targeted to ASP.NET 2.0. I added .NET 3.0 Framework features to the server role. I've already gone through all of the steps involving *.svc extensions and the aspnet_isapi module. I've run "ServiceModelReg -r" and restarted IIS as well as the server itself.
My project targets the .NET framework 3.5 for builds. My solution references the project as a Web site using a UNC path to the server's Web directory. The project builds without errors and I can successfully add a service reference to my WCF service in my client project (on my Win XP development virtual machine). My client project builds and runs, but throws an exception during the service method (CheckDatabaseConnection) call. My web.config and service classes are attached below, followed by the client app. I've completely run out of ideas!
web.config:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false" />
<services>
<service behaviorConfiguration="ConnectivityBehavior" name="EDCO.Web.Services.Connectivity">
<endpoint address="http://validurl.net" binding="wsHttpBinding" contract="EDCO.Web.Services.IConnectivity">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ConnectivityBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
IConnectivity.cs:
[ServiceContract(Namespace="http://validurl.net")]
public interface IConnectivity
{
#region Methods
[WebGet()]
[WebInvoke(Method="GET")]
[OperationContract()]
bool CheckDatabaseConnection(string server, string database, string user, string password);
#endregion Methods
} // interface IConnectivity
Connectivity.svc.cs:
public class Connectivity : IConnectivity
{
#region Members
const string CONN_STRING = "Server={0};Database={1};User ID={2};Password={3};";
#endregion Members
#region Methods
public bool CheckDatabaseConnection(string server, string database, string user, string password)
{
SqlConnection conn = null;
try
{
conn = new SqlConnection(string.Format(CONN_STRING, server, database, user, password));
conn.Open();
}
catch
{
return false;
}
finally
{
if (conn != null)
{
if (conn.State != ConnectionState.Closed)
{
conn.Close();
}
conn.Dispose();
}
}
return true;
} // CheckDatabaseConnection(server, database, user, password)
#endregion Methods
} // class Connectivity
client Program.cs:
class Program
{
#region Methods
static void Main(string[] args)
{
Connectivity.ConnectivityClient connect = new Connectivity.ConnectivityClient();
Console.WriteLine("Establishing connection...");
if (connect.CheckDatabaseConnection("dbServer", "dbName", "login", "password"))
{
Console.WriteLine("Successful connection!");
}
else
{
Console.WriteLine("Connection failed.");
}
Console.ReadLine();
} // Main()
#endregion Methods
} // class Program