I am relatively new to WCF. However, I need to create a service that exposes data to both Silverlight and AJAX client applications. In an attempt to accomplish this, I have
Remove the namespace from Service name. It will work fine.
Modify your web.config
You can find <services>
tag and below of this tag you have to have two other tag :
<service ....
And
<endpoint ....
In <endpoint>
tag you have to reference to interface of your class.
For exampl : If your service class named CustomerSearch
and your interface named ICustomerSearch
you have to config like this :
<service name="CustomerSearch" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="webHttpBinding" contract="ICustomerSearch"
behaviorConfiguration="ServiceAspNetAjaxBehavior">
I had the same issue, but my solution was that in my web.config, I was specifying the entire class name (including namespace), whereas WCF would only accept a class name.
This didn't work:
<services>
<service name="BusinessServices.Web.RfsProcessor">
This worked:
<services>
<service name="RfsProcessor">
Your contract is the Interface not the implementation.
Somewhere in the config you have written myService instead of IJsonService.
I have had that error before for ServiceModel framework 3.5, and I checked my host's config file. I found it was my cut-and-paste error. My service was pointing to an old non-existing service than the one I am using. It starts working again after I corrected these lines like below:
<system.serviceModel>
<services>
<!--<service name="NotUsed.Serv">-->
<service name="InUse.MyService">
<host>
<baseAddresses>
<!--<add baseAddress="http://localhost:8181/LastService" />-->
<add baseAddress="http://localhost:8181/InUseService"/>
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
Note that MyService has to be the name of your contract class in ServiceModel 3.5 BUT IT IS IMyService contract interface in Framework 4.0 -->
namespace InUse {
[ServiceContract]
public interface IMyService
{
[WebGet(UriTemplate = "/GetList/{PATTERN}",
RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json)]
[OperationContract]
List<string> GetIDListByPattern(string PATTERN);
}
[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
public class MyService : IMyService
{
List<string> MySample = (new _PointRT()).Sample().Select(r=>r._pointXID).ToList();
public List<string> GetIDListByPattern(string PATTERN) {
return MySample.Where(x => x.Contains(PATTERN)).ToList();
}
}
In the web.config
file, the <service
element's name
attribute needs to be the service type's name with the namespace, but not the assembly (Namespace1.Namespace2.Class
). The <endpoint
element's contract
attribute similarly has namespace-qualified interface type - Namespace1.Namespace2.Interface
.
This also solves all behavior shenanigans, like CreateBehavior
not being invokes on BehaviorExtensionElement
.