I’m trying to figure out WCF Services. I got 1 to work 1 time and now I can’t seem to get this to work at all (even following the previous examples). I don’t understand several things about the WCF Services. For example why does it need endpoints. What purpose do they serve? However, if any one could help me get past this error that would be great.
I’m trying to setup a default WCF Service. I haven’t added any code. I’m just trying to get the service to display.
I have pilltrakr.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace serviceContract
{
public class pilltrakr : Ipilltrakr
{
public void DoWork()
{
}
}
}
I have Ipilltrakr:
namespace serviceContract
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "Ipilltrakr" in both code and config file together.
[ServiceContract]
public interface Ipilltrakr
{
[OperationContract]
void DoWork();
}
}
I have: pilltrakr.svc
<%@ ServiceHost Language="C#" Debug="true" Service="pilltrakr" CodeBehind="~/App_Code/pilltrakr.cs" %>
In my web.config I have the following:
<system.serviceModel>
<services>
<service name="serviceContract.pilltrakr" behaviorConfiguration="InternalWebService">
<endpoint contract="serviceContract.Ipilltrakr" binding="basicHttpBinding" address="pilltrakr"
bindingConfiguration="InternalHttpBinding" bindingNamespace="serviceContract"/>
</service>
</services>
</system.serviceModel>
I’m getting the following error:
Server Error in ‘/pilltrakr’ Application. The type ‘pilltrakr’,
provided as the Service attribute value in the ServiceHost directive,
or provided in the configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations could
not be found. Description: An unhandled exception occurred during the
execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the
code.Exception Details: System.InvalidOperationException: The type
‘pilltrakr’, provided as the Service attribute value in the
ServiceHost directive, or provided in the configuration element
system.serviceModel/serviceHostingEnvironment/serviceActivations could
not be found.
You need to specify the exact name of the service class in your
.svcfile including namespace:As far as your question about endpoints is concerned, they are used to define at what address the service will respond and what binding it will use. For example you could expose your service on 2 different endpoints => one using SOAP and other using REST.