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