简体   繁体   English

基本的wcf服务返回错误服务''具有零个应用程序(非基础结构)端点

[英]basic wcf service returns error Service '' has zero application (non-infrastructure) endpoints

I have created a blank web application and added an ajax enabled wcf service. 我创建了一个空白的Web应用程序,并添加了启用了Ajax的wcf服务。 I have not modified the actual svc.cs file I am using what was provided by the template 我尚未修改模板所提供的实际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]
}

} }

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. 服务“ SP.WebWCF.ActivateCardV1”的应用程序端点(非基础结构)为零。 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? 我究竟做错了什么?

Start by simplifying and standardizing your service configuration xml: 首先简化和标准化服务配置xml:

  1. Use wsHttpBinding. 使用wsHttpBinding。
  2. Use http instead of https. 使用http而不是https。
  3. Remove ListenUri and isSystemEndpoint 删除ListenUri和isSystemEndpoint
  4. Remove the behavior configuration attribute. 删除行为配置属性。
  5. Add the contract name to the path. 将合同名称添加到路径。

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. 还要从类的ContractAttribute中删除(Namespace = "") -我不确定这样做是什么,但您是在配置xml的contract属性中指定Namespace的。

Once you've simplified your configuration it should look something like this: 简化配置后,它应如下所示:

<service name="SP.WebWCF.ActivateCardV1">
    <endpoint address="http://services.mydomain.com/ActivateCardV1" binding="wsHttpBinding" contract="SP.WebWCF.ActivateCardV1"/>
</service>

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?). 如果不起作用,则应该更容易进行故障排除(是否将任何错误写入IIS日志?)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM