Adding a WCF service into a subfolder
I have created a new wcf4 web application and added a new wcf service. I created a subfolder and moved the service created into the subfolder.
e.g.
ROOT
ROOT/Business/V1/BusinessV1.svc
I have deployed the service onto my IIS7 enviroment however I keep getting this error
The type 'MyNameSpace.WebWCF.Business.V1', provided as the Service attribute value in the ServiceHost directive, or provided in the configuration element system.serviceModel/serviceHostingEnvironment/serviceActivations could not be found.
My service 开发者_如何学JAVAfile looks like this
<%@ ServiceHost Language="C#" Debug="true"
Service="MyNameSpace.WebWCF.BusinessV1" CodeBehind="BusinessV1.svc.cs" %>
The code behind looks like
namespace MyNameSpace.WebWCF
{
public class BusinessV1 : IBusinessV1
{
}
}
My contract looks like
namespace MyNameSpace.WebWCF
{
[ServiceContract]
public interface IBusinessV1
}
Finally my web.config
<system.serviceModel>
<services>
<service name="MyNameSpace.WebWCF.Business_v1">
<endpoint
address="http://mydomain.com/Business/v1/BusinessV1.svc"
binding="basicHttpBinding"
bindingConfiguration=""
contract="MyNameSpace.WebWCF/IBusinessV1"
listenUri="/" isSystemEndpoint="true" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
Can someone please help me with what I am doing wrong? its driving me crazy.
Well one thing is: your service name isn't consistent.
In your service implementation class, you have:
namespace MyNameSpace.WebWCF
{
public class BusinessV1
and in your *.svc
file, you have the same qualified name:
Service="MyNameSpace.WebWCF.BusinessV1"
but in your web.config
, you use:
<service name="MyNameSpace.WebWCF.Business_v1">
Your service implementation is the one that defines the service name - fully qualified with the namespace: MyNameSpace.WebWCF.BusinessV1
So you need to use this fully qualified name - and exactly that - in your *.svc
file (OK!) and your web.config
:
<service name="MyNameSpace.WebWCF.BusinessV1">
Use MyNameSpace.WebWCF.BusinessV1
insstead of MyNameSpace.WebWCF.Business_v1
.
If that name doesn't match, the WCF runtime won't find the config you've specified and will fall back to system defaults
Two questions which hopfeully may help:
1st: Are you sure the contract still corresponds to the webservice after moving?
and/or
2nd: Have you updated the webservices (from the context menu of the web service entry in the project list; atm. i have no VS to be more specific).
精彩评论