I've built a small WCF service that I'm trying to build unit tests for. I've deployed this service with a database locally and the service works and can save and read data from the database. I created a separate project within the same solution as a Console Application with a service reference to consume this service.
Here is what the code looks like:
Service Contract
[ServiceContract]
public interface IUserService
{
//When testing in the browser use verb GET
[OperationContract]
[WebInvoke(Method="POST", UriTemplate = "/CreateNewUserAccount?userNameValue={userName})]
void CreateNewUserAccount(string userName);
}
Service Implementation:
public void CreateNewUserAccount(string userName)
{
var userContorller = new UserController();
userContorller.addNewUser(userName);
}
Console Client with service reference:
static void Main(string[] args)
{
try
{
UserServiceClient serviceClient = new UserServiceClient("");
}
catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.ReadKey();
}
Here is a sample of how I call the service in the browser: http://localhost:8654/Services/UserService/UserService.svc/CreateNewUserAccount?userNameValue=testUser
I've confirmed that this works when I run the service locally. Now the exception I'm receiving from the console client is:
Could not find endpoint element with name '' and contract 'SerficeReference.IUserService' in the ServiceModel client configuration section.
It looks like I'm missing endpoints and nothing was generated in the app.config when I linked the service reference. I've tried numerous configurations in the app.config but I can't seem to get this straight. The exception occurs when I try to instantiate the service client in the console app. My app.config looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
Any help would be appreciated.