2

这个问题可能与TFS 2010 向 WCF 4.0 服务发送 SOAP 警报时出现 404 错误这个问题非常相似, 但我不知道我哪里出错了。(所以希望Ewald能插嘴)

我浏览了所有我能找到的样本和问题,但不知何故,我仍然没有收到任何警报。

我的测试实现部署在 azure 上,我配置了我的免费 tfs 服务 (***.visualstudio.com) 以实际将新工作项发布到该端点。

当我自己创建客户端代理时,我可以看到数据到达。那么代码/配置中一定还是有问题吗?

namespace Tfs.NotificationService
{
    [ServiceContract(Namespace = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")]
    public interface INotifyService
    {
        [OperationContract(Action = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/Notify")]
        [XmlSerializerFormat(Style = OperationFormatStyle.Document)]
        void Notify(string eventXml, string tfsIdentityXml);
    }

    public class NotifyService : INotifyService
    {
        void INotifyService.Notify(string eventXml, string tfsIdentityXml)
        {
            using (var db = new NotificationContext())
            {
                db.Notifications.Add(new Notification { EventXml = eventXml, TfsIdendityXml = tfsIdentityXml });
                db.SaveChanges();
            }
        }
    }
}

web.config 文件:

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="NotifyServiceBinding">
          <security mode="None" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="NotifyServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="NotifyServiceBehavior" name="Tfs.NotificationService.NotifyService">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="NotifyServiceBinding"
                  contract="Tfs.NotificationService.INotifyService" />
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

项目是一个 ASP.Net MVC 4 - .Net 4.5 - 使用 EF 5.0 来存储数据。

4

1 回答 1

3

工作解决方案:

namespace Tfs.NotificationService
{
    [ServiceContract(Namespace = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")]
    public interface INotifyService
    {
        [OperationContract(Action = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/Notify")]
        [XmlSerializerFormat(Style = OperationFormatStyle.Document)]
        void Notify(string eventXml, string tfsIdentityXml);
    }

    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class NotifyService : INotifyService
    {
        void INotifyService.Notify(string eventXml, string tfsIdentityXml)
        {
            // do something
        }
    }
}

网络配置:

  <system.serviceModel>
    <bindings>
      <wsHttpBinding>
        <binding name="NotifyServiceBinding">
          <security mode="None" />
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="NotifyServiceBehavior">
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <services>
      <service behaviorConfiguration="NotifyServiceBehavior" name="Tfs.NotificationService.NotifyService">
        <endpoint address="" binding="wsHttpBinding" bindingConfiguration="NotifyServiceBinding"
                  contract="Tfs.NotificationService.INotifyService" />
      </service>
    </services>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
于 2014-04-18T08:09:42.323 回答