简体   繁体   中英

SOAP Alerts for Team Foundation Service

This question is probably very similar to 404 Error when TFS 2010 Sends SOAP Alert to a WCF 4.0 Service or this but I can not figure out where I went wrong. (So hoping that Ewald will chime in)

I went through all the samples and questions that I could find, but somehow, I still do not get any alerts to come through.

My test implementation is deployed on azure and I configured my free tfs service (***.visualstudio.com) to actually post new work items to that endpoint.

When I create a client proxy myself, I can see the data arrive. So something must still be wrong in the code/configuration?

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();
            }
        }
    }
}

The web.config file:

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

Project is a ASP.Net MVC 4 - .Net 4.5 - with EF 5.0 to store the data.

Working solution:

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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