Bonjour à tous.
Je me bats depuis quelques jours pour abonner mon WebService aux notifications de TFS.
J'ai créé un WebService en C# qui expose la fonction. La seule chose que fait ce WS est de recopier les arguments de Notify (eventXML, tfsIdentityXML et SubscriptionInfo) dans un fichier texte.
Code : Sélectionner tout - Visualiser dans une fenêtre à part public void Notify(string eventXml, string tfsIdentityXml, SubscriptionInfo SubscriptionInfo)
J'ai donc inscrit ce webservice à la notification "WorkItemChanged" de TFS avec l'utilitaire Bissubscribe.exe fourni avec TFS.
Le problème se produit quand, en tant qu'utilisateur de Visual Studio Team System sur un autre poste, je modifie l'état d'un WorkItem en faisant par exemple passer le champ "status" de "Ouvert" à "Fermé": mon webservice est bien notifié de ce changement mais les champs eventXML et SubscriptionInfo sont nuls !!
Voilà. je reçois bien la notification mais je ne peux rien en faire...
Si vous avez des pistes !!
Le WebService:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102 using System; using System.Collections.Generic; using System.Linq; using System.IO;//pour FileStream, utilisé pour les tests, à supprimer après using System.Text;//pour Encoding, idem using System.Web; using System.Web.Services; using System.Web.Services.Protocols; // pour SoapDocumentMethod using System.Xml; using System.Xml.Serialization; using Microsoft.TeamFoundation.Server; using System.Windows.Forms;// <--- pour messageBox namespace monWebService { public abstract class EndPointBase : WebService { protected T CreateInstance<T>(string serializedType) where T : new() // T doit disposer d'un constructeur sans paramètre { XmlDocument doc = new XmlDocument();//représente un document XML doc.LoadXml(serializedType);//charge le document à partir de la chaîne return (T)new XmlSerializer(typeof(T)).Deserialize(new XmlNodeReader(doc));//recrée l'objet de type T } public abstract void Notify(string eventXML, string tfsIdentityXml, SubscriptionInfo subscriptionInfo); } [WebService(Namespace = "http://localhost/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] public class WorkItemChangedEndPoint : EndPointBase { [WebMethod] [SoapDocumentMethod("http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03/Notify", RequestNamespace = "http://schemas.microsoft.com/TeamFoundation/2005/06/Services/Notification/03")] public override void Notify(string eventXML, string tfsIdentityXml, SubscriptionInfo subscriptionInfo) { FileStream stream = File.Create(@"D:\webservice\monWebService\log1.txt"); if (stream.CanWrite) { StreamWriter monWriter = new StreamWriter(stream); monWriter.AutoFlush = true; monWriter.WriteLine("autorisation d'écriture : OK"); if (eventXML == null) { monWriter.WriteLine("eventXML == null"); } else { monWriter.WriteLine("eventXML: " + eventXML); } if (tfsIdentityXml == null) { monWriter.WriteLine("tfsIdentityXml == null"); } else { monWriter.WriteLine("tfsIdentityXml: " + tfsIdentityXml); } if (subscriptionInfo == null) { monWriter.WriteLine("subscriptionInfo == null"); } else { monWriter.WriteLine("subscriptionInfo: "); if (subscriptionInfo.Classification != null) { monWriter.WriteLine("classification: " + subscriptionInfo.Classification); } if (subscriptionInfo.Subscriber != null) { monWriter.WriteLine("Suscriber: " + subscriptionInfo.Subscriber); } monWriter.WriteLine("ID: " + subscriptionInfo.ID.ToString()); } monWriter.Close(); } } [WebMethod] public string WriteHello() { return "Hello"; } } }
Partager