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

时间:2010-11-27 05:49:44

标签: .net wcf exception-handling asp.net-ajax wcf-endpoint

我创建了一个空白的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>

但是当我尝试点击服务时出现错误

  

Service&#39; SP.WebWCF.ActivateCardV1&#39;没有应用程序(非基础结构)端点。这可能是因为没有为您的应用程序找到配置文件,或者因为在配置文件中找不到与服务名称匹配的服务元素,或者因为在服务元素中没有定义端点。

我做错了什么?

1 个答案:

答案 0 :(得分:1)

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

  1. 使用wsHttpBinding。
  2. 使用http代替https。
  3. 删除ListenUri和isSystemEndpoint
  4. 删除行为配置属性。
  5. 将合同名称添加到路径中。
  6. 同样从类中的ContractAttribute中删除(Namespace = "") - 我不确定它是做什么的,但是你在配置xml的contract属性中指定了Namespace。

    一旦简化了配置,它应该是这样的:

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

    如果它有效,你可以开始添加复杂性,以找出打破它的原因。如果它不起作用,则应该更容易进行故障排除(写入IIS日志的错误是什么?)。