基本 wcf 服务返回错误服务 ''具有零个应用程序(非基础设施)端点
我创建了一个空白的 Web 应用程序并添加了启用 ajax 的 wcf 服务。 我没有修改实际的 svc.cs 文件,我正在使用模板提供的文件
namespace SP.WebWCF {
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ActivateCardV1 {
// To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
// To create an operation that returns XML,
// add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
// and include the following line in the operation body:
// WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
[OperationContract]
public void DoWork() {
// Add your operation implementation here
return;
}
// Add more operations here and mark them with [OperationContract]
}
}
我已经稍微更新了配置,看起来像这样
<service name="SP.WebWCF.ActivateCardV1">
<endpoint address="https://services.mydomain.com" behaviorConfiguration="SP.WebWCF.ActivateCardV1AspNetAjaxBehavior"
binding="webHttpBinding" contract="SP.WebWCF.ActivateCardV1" listenUri="/" isSystemEndpoint="true" />
</service>
但是,当我尝试点击服务时,我收到错误
服务“SP.WebWCF.ActivateCardV1”具有零个应用程序(非基础设施)端点。这可能是因为没有找到您的应用程序的配置文件,或者因为在配置文件中找不到与服务名称匹配的服务元素,或者因为在服务元素中没有定义端点。
我做错了什么?
I have created a blank web application and added an ajax enabled wcf service.
I have not modified the actual svc.cs file I am using what was provided by the template
namespace SP.WebWCF {
[ServiceContract(Namespace = "")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ActivateCardV1 {
// To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
// To create an operation that returns XML,
// add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
// and include the following line in the operation body:
// WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
[OperationContract]
public void DoWork() {
// Add your operation implementation here
return;
}
// Add more operations here and mark them with [OperationContract]
}
}
I have updated the config slightly to look like this
<service name="SP.WebWCF.ActivateCardV1">
<endpoint address="https://services.mydomain.com" behaviorConfiguration="SP.WebWCF.ActivateCardV1AspNetAjaxBehavior"
binding="webHttpBinding" contract="SP.WebWCF.ActivateCardV1" listenUri="/" isSystemEndpoint="true" />
</service>
However when I try hit the service I get an error
Service 'SP.WebWCF.ActivateCardV1' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.
WHat am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先简化和标准化您的服务配置 xml:
还要从类中的 ContractAttribute 中删除
(Namespace = "")
- 我不确定它的作用,但您在配置 xml 的契约属性中指定命名空间。一旦您简化了配置,它应该看起来像这样:
如果它有效,您可以开始增加复杂性以找出破坏它的原因。如果它不起作用,应该更容易排除故障(是否有任何错误写入 IIS 日志?)。
Start by simplifying and standardizing your service configuration xml:
Also remove
(Namespace = "")
from the ContractAttribute in your class - I'm not sure what that does but you are specifying the Namespace in the contract attribute of the configuration xml.Once you've simplified your configuration it should look something like this:
If it works, you can start adding complexity back to it to find out what breaks it. If it doesn't work it should be easier to troubleshoot (are any errors written to the IIS logs?).