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

发布于 2024-10-05 05:25:06 字数 1401 浏览 6 评论 0原文

我创建了一个空白的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不爱素颜 2024-10-12 05:25:06

首先简化和标准化您的服务配置 xml:

  1. 使用 wsHttpBinding。
  2. 使用 http 而不是 https。
  3. 删除 ListenUri 和 isSystemEndpoint
  4. 删除行为配置属性。
  5. 将合约名称添加到路径中。

还要从类中的 ContractAttribute 中删除 (Namespace = "") - 我不确定它的作用,但您在配置 xml 的契约属性中指定命名空间。

一旦您简化了配置,它应该看起来像这样:

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

如果它有效,您可以开始增加复杂性以找出破坏它的原因。如果它不起作用,应该更容易排除故障(是否有任何错误写入 IIS 日志?)。

Start by simplifying and standardizing your service configuration xml:

  1. Use wsHttpBinding.
  2. Use http instead of https.
  3. Remove ListenUri and 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.

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?).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文