很抱歉提出一些我不太了解的问题,但是我一直在试着让我的头发工作。
所以,我有一个托管在IIS上的WCF服务,似乎工作得很好,我可以通过浏览器中的http://servername/MyService.svc在网络上“看到”它。
那.svc看起来像:
<% @ServiceHost Service="Foo.Bar" %>
相关代码如下:
[ServiceContract(Namespace = "http://schemas.microsoft.com/TeamFoundation/2005/06Services/Notification/03")]
public interface IBar
{
[OperationContract(Action = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/Notify", ReplyAction = "*")]
[XmlSerializerFormat(Style = OperationFormatStyle.Document)]
void Notify(string eventXml, string tfsIdentityXml);
}
和
public class Bar : IBar
{
public void Notify(string eventXml, string tfsIdentityXml)
{
// Just some test output to see if it worked
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "tfs.txt");
File.WriteAllText(path, tfsIdentityXml + eventXml);
}
}
这一切都已经构建完毕,随后的.dll会放入IIS中站点根目录的bin目录中。
我现在想通过bissubscribe.exe(或类似的方法)订阅TFS签到事件。我尝试过这样的事情:
bissubscribe /eventType CheckinEvent
/address http://servername/MyService.svc
/deliveryType Soap
/server mytfsserver
但没有;它甚至看起来没有日志活动。所以请记住,我对WCF一无所知,我做错了什么?我想address
param是一回事;我不应该把它指向.svc吗?
答案 0 :(得分:3)
我创建了一篇博文,介绍如何将WCF与TFS的事件服务结合使用:http://www.ewaldhofman.nl/post/2010/08/02/How-to-use-WCF-to-subscribe-to-the-TFS-2010-Event-Service-rolling-up-hours.aspx
答案 1 :(得分:2)
TFS 2010和WCF 4.0配置如下所述......
方法签名:
public void Notify(string eventXml) /* No SubscriptionInfo! */
网络配置:
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="Microsoft.TeamFoundation, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
</assemblies>
</compilation>
</system.web>
<system.serviceModel>
<services>
<service behaviorConfiguration="NotificationServiceBehavior" name="TF.CheckinListener.CheckinListener">
<endpoint address="Notify" binding="wsHttpBinding" bindingConfiguration="noSecurity" contract="TF.CheckinListener.ICheckinListener" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="NotificationServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
</binding>
<wsHttpBinding>
<binding name="noSecurity" maxBufferPoolSize="20000000" maxReceivedMessageSize="200000000">
<readerQuotas maxStringContentLength="200000000" maxArrayLength="200000000" />
<security mode="None" />
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>
bissubscribe的订阅地址:
答案 2 :(得分:1)
跳出来的一点是你有一个方法除了void
之外什么都不返回。那些应该在WCF中标记为“单向”方法:
[ServiceContract(Namespace = "http://schemas.microsoft.com/TeamFoundation/2005/06Services/Notification/03")]
public interface IBar
{
[OperationContract(Action = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/Notify", ReplyAction = "*", IsOneWay=true)]
[XmlSerializerFormat(Style = OperationFormatStyle.Document)]
void Notify(string eventXml, string tfsIdentityXml);
}
将“IsOneWay = true”添加到您的[OperationContract]
属性。
除此之外,你的代码没有明显的错误,但要真正告诉我们,我们需要更多的配置信息来真正说明。首先尝试IsOneWay=true
,看看是否能解决您的问题。
答案 3 :(得分:1)
您的服务是如何配置的?特别是,它是否配置为使用basicHttpBinding
?
尝试创建一个客户端来调用您的服务,以确保可以调用它。
然后,看看是否有来自TFS SDK的示例服务 - 看看你是否可以让这个例子起作用。
答案 4 :(得分:1)
我能够通过以下方式完成此连接:
[ServiceContract(Namespace = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")]
public interface ITeamSystemObserver : IObservable
{
[OperationContract( Action = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/Notify", ReplyAction = "*" )]
[XmlSerializerFormat(Style=OperationFormatStyle.Document)]
void Notify(string eventXml, string tfsIdentityXml, SubscriptionInfo SubscriptionInfo);
}
请注意,您缺少SubscriptionInfo参数。这是我的web.config:
<basicHttpBinding>
<binding name="TfsEventServiceBasic">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" />
</security>
</binding>
</basicHttpBinding>