wcf - Team Foundation 服务的 SOAP 警报

标签 wcf soap tfs azure-devops

这个问题可能非常类似于 404 Error when TFS 2010 Sends SOAP Alert to a WCF 4.0 Servicethis 但我不知道我哪里错了。 (所以希望 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 来存储数据。

最佳答案

工作解决方案:

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
        }
    }
}

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>

关于wcf - Team Foundation 服务的 SOAP 警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19861263/

相关文章:

c# - gzip 流并使用 WCF 发送它

ruby - 如何从 Savon::SOAPFault 获取错误代码和描述?

tfs - 如何确定在 TFS 中触发发布的构建定义?

wcf - Windows Azure 队列、WCF、MSMQ 集成

c# - SOAP 的 WSDL - REST 怎么样?

java - 在 Spring 中设置 Soap 请求的 header

tfs - 分支机构政策:要求指定批准者至少有1个批准

visual-studio-2008 - TFS 工作区

C# 文件位置难题

rest - SpringBoot RestController 为路径 'services/*' 返回 405