在 OperationContract 中指定操作会导致 WSDL 中不生成任何操作
Specifying action in OperationContract results in no action generated in WSDL
我有一个奇怪的问题,我一直在扯头发。我正在尝试在 WCF 中创建 TFS 事件处理程序服务,部分要求是生成具有特定命名空间和操作的 SOAP 1.2 信封。
基本界面如下所示:
[ServiceContract(Namespace="http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")]
public interface ITfsNotificationService
{
[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);
}
但是,当我尝试使用 WcfTestClient 访问此服务时出现错误,并且界面中没有显示任何方法:
The contract 'ITfsNotificationService' in client configuration does not
match the name in service contract, or there is no valid method in this
contract.
但是,如果我从操作合同中删除操作 属性,它运行良好(但会有错误的 Action 方法,其中包括接口名称)并且没有任何错误。显然错误是指消息的后半部分(或者这个合约中没有有效的方法)
当我查看生成的 WSDL 时,使用操作 属性 时没有生成操作元素,但是当我指定空 [OperationContract]
.
时有
关于我在这里做错了什么的任何线索?
仅供参考,这是基于此处的示例:http://www.ewaldhofman.nl/post/2010/08/02/how-to-use-wcf-to-subscribe-to-the-tfs-2010-event-service-rolling-up-hours.aspx
我对此很好奇,所以我在这里尝试并工作。
这是我所做的:
[ServiceContract(Namespace = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")]
public interface ITfsNotificationService
{
[OperationContract(Action = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/Notify", Name = "Notify", ReplyAction = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/ResponstToNotify")]
[XmlSerializerFormat(Style = OperationFormatStyle.Document)]
void Notify(string eventXml, string tfsIdentityXml, SubscriptionInfo SubscriptionInfo);
}
[ServiceBehavior(Namespace = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")]
public class Service1 : ITfsNotificationService
{
public void Notify(string eventXml, string tfsIdentityXml, SubscriptionInfo SubscriptionInfo)
{
throw new NotImplementedException();
}
}
希望对您有所帮助。
我有一个奇怪的问题,我一直在扯头发。我正在尝试在 WCF 中创建 TFS 事件处理程序服务,部分要求是生成具有特定命名空间和操作的 SOAP 1.2 信封。
基本界面如下所示:
[ServiceContract(Namespace="http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")]
public interface ITfsNotificationService
{
[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);
}
但是,当我尝试使用 WcfTestClient 访问此服务时出现错误,并且界面中没有显示任何方法:
The contract 'ITfsNotificationService' in client configuration does not
match the name in service contract, or there is no valid method in this
contract.
但是,如果我从操作合同中删除操作 属性,它运行良好(但会有错误的 Action 方法,其中包括接口名称)并且没有任何错误。显然错误是指消息的后半部分(或者这个合约中没有有效的方法)
当我查看生成的 WSDL 时,使用操作 属性 时没有生成操作元素,但是当我指定空 [OperationContract]
.
关于我在这里做错了什么的任何线索?
仅供参考,这是基于此处的示例:http://www.ewaldhofman.nl/post/2010/08/02/how-to-use-wcf-to-subscribe-to-the-tfs-2010-event-service-rolling-up-hours.aspx
我对此很好奇,所以我在这里尝试并工作。 这是我所做的:
[ServiceContract(Namespace = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")]
public interface ITfsNotificationService
{
[OperationContract(Action = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/Notify", Name = "Notify", ReplyAction = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/ResponstToNotify")]
[XmlSerializerFormat(Style = OperationFormatStyle.Document)]
void Notify(string eventXml, string tfsIdentityXml, SubscriptionInfo SubscriptionInfo);
}
[ServiceBehavior(Namespace = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")]
public class Service1 : ITfsNotificationService
{
public void Notify(string eventXml, string tfsIdentityXml, SubscriptionInfo SubscriptionInfo)
{
throw new NotImplementedException();
}
}
希望对您有所帮助。