I'm hosting my WCF service on IIS 7, even though it is working fine when using the WCF Test Client, I cannot consume my service from a simple console application.
I've already allowed the handling of .svc and .wsdl files on my IIS. I'm not sure what else am I missing.
Here is my code:
namespace EvalServiceLibrary {
[ServiceContract]
public interface IEvalService {
[OperationContract]
void SubmitEval(Eval eval);
[OperationContract]
List<Eval> GetEvals();
[OperationContract]
void RemoveEval(String id);
}
}
namespace EvalServiceLibrary {
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class EvalService : IEvalService {
#region
List<Eval> evals = new List<Eval>();
public void SubmitEval(Eval eval) {
eval.Id = Guid.NewGuid().ToString();
evals.Add(eval);
}
public List<Eval> GetEvals() {
return evals;
}
public void RemoveEval(String id) {
evals.Remove(evals.Find(e => e.Id.Equals(id)));
}
#endregion
}
}
And my web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
</system.web>
<system.serviceModel>
<services>
<service name="EvalServiceLibrary.EvalService">
<endpoint address="http://localhost/WebEvalService" binding="basicHttpBinding"
bindingConfiguration="" name="basicHttpBinding" contract="EvalServiceLibrary.IEvalService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="false"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
Here's my client code:
static void Main(string[] args) {
EvalServiceClient client = new EvalServiceClient();
client.SubmitEval(new Eval() { Comments = "Lorem Ipsum", Submitter = "egarcia", TimeSubmitted = DateTime.Now });
List<Eval> evalList = client.GetEvals().ToList();
foreach(var eval in evalList) {
Console.WriteLine(eval.Id);
}
client.Close();
}
I can access the service on my local IIS as well.