VSTS Extensibility, Subscription API, IEventService

I was testing out the the extensibility sample for subscription to CheckInEvent, I got back a reference to the IEventService and used the subscribe method for notification to CheckInEvents, I made the DeliveryType as Soap and Created the Web service with the specified Notify method as follows


[SoapDocumentMethod(Action = "http://Microsoft.VisualStudio.Bis/Notify")]

[WebMethod]

public void Notify(string eventXml)

{

if (eventXml == string.Empty)
  throw new ApplicationException("event parameter is empty");

}


 



Everything is working fine, the console app is subscribing to the event, the web method is being called, the problem is the parameter value (eventXml) is always emtpy, do i need to do anything on the web service to get the value of the CheckInEvent

Also on a side note, If I setup an Email Alert for CheckIn from within the IDE, I am getting the complete information with alll the changes that happened with a specific check-in event, so its the custom subscription through the Extensibility kit thats not working or I am missing some config...any pointers would be helpful.



Answer this question

VSTS Extensibility, Subscription API, IEventService

  • shashankk

    Where have you hosted your webservice is it on the same box that has the Sharepoint and SQL Server 2005 beta 2 If so you would need to exclude the web service virtual directory from the sharepoint, you can do this by following the same process you did for excluding the sql reporting services 2005 in a single server installation. If thats not the case, make sure the web service directory / page has only integrated authentication [anonymous access disabled] and the client computer allows access to the Service account the TFS Server is running under (normally TFSService if the default installation steps were followed).

    Thanks,
    Krishna


  • f a c


    This often happens when the parameter name of your Notify method is not exactly 'eventXml'.  Webmethods use reflection to map the SOAP xml to the arguments, and when the names don't match exactly, the argument is left as the default null.

  • Shabbar Husain

    Oh and here is the Subscription code ...


                try
                {
                    string tfsServer = "foundationserver";
                    TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(tfsServer);
                    IEventService eventService = tfs.GetService(typeof(IEventService)) as IEventService;
                    DeliveryPreference delivery = new DeliveryPreference();
                    delivery.Type = DeliveryType.Soap;
                    delivery.Schedule = DeliverySchedule.Immediate;
                    delivery.Address = "http://tfsclient2/checkinnotification/service.asmx";
                    int id = eventService.Subscribe(@"DEV03\Krishna", "CheckInEvent", "", delivery);
                    if (id < 0)
                        throw new ApplicationException("Unable to subscribe...");
                    Console.WriteLine("Press enter to Exit...");
                    Console.ReadLine();
                    eventService.Unsubscribe(id);
                }

                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.ReadLine();
                }


     


  • Tony Dong

    How does the connection between the app and webservice happen I created the console app and web service. I ran the console app and then modified an existing workitem. In the service I just write out the eventXML to a local file. Is there something else that I'm missing

    Thx
    Ranjith


  • CraigInGeorgia

    This works for me.  Maybe you need the RequestNamespace set

        [SoapDocumentMethod("http://Microsoft.VisualStudio.Bis/Notify",
        RequestNamespace = "http://Microsoft.VisualStudio.Bis")]
        [WebMethod]
        public EventResult Notify(string eventXml)
        {
            ...
        }

  • James Huang

    The sample had the argument as eventXml, this is what i tried first, the Event Servicing Spec. from the VSTS extensibility kit had it as bisEvent which I tried second, in both the cases the parameter for the CheckinEvent is coming always null..any other pointers


  • russc243

    Hi Krishna,
       Thanks for your response.
       Eventing Service is working fine for 'WorkItemChangedEvent' Big Smile
    Sonali

  • Babbage

    Hi Krishnawin,
       I am having a problem with the eventing service.
       I tried using the code snippet sent in ur post.

       These are the steps I had carried out
       
    ===========
      WebService
    ===========
    Code in Service.cs

    using System;

    using System.Web;

    using System.Web.Services;

    using System.Web.Services.Protocols;

    [WebService(Namespace = "http://tempuri.org/")]

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

    public class Service : System.Web.Services.WebService

    {

    public Service ()

    {}

    [SoapDocumentMethod("http://Microsoft.VisualStudio.Bis/Notify",

    RequestNamespace = "http://Microsoft.VisualStudio.Bis")]

    [WebMethod]

    public void Notify(string eventXml)

    {

    if (eventXml == string.Empty)

    throw new ApplicationException("event parameter is empty");

    }

    }


    =========
    Subscription
    ==========
    Code

    using System;

    using System.Collections.Generic;

    using System.Text;

    using Microsoft.VisualStudio.Bis.Proxy;

    using Microsoft.VisualStudio.Bis.Services;

    using Microsoft.VisualStudio.TeamFoundation.Client;

    namespace EventSubscription

    {

    class Program

    {

    static void Main(string[] args)

    {

    try

    {

    string tfsServer = "tcs046247.testdom";

    TeamFoundationServer tfs = TeamFoundationServerFactory.GetServer(tfsServer);

    IEventService eventService = tfs.GetService(typeof(IEventService)) as IEventService;

    DeliveryPreference delivery = new DeliveryPreference();

    delivery.Type = DeliveryType.Soap;

    delivery.Schedule = DeliverySchedule.Immediate;

    delivery.Address = "http://tcs046247:11900/Service.asmx";

    int id = eventService.Subscribe(@"testdom\142575", "WorkItemChangedEvent", "", delivery);

    if (id < 0)

    throw new ApplicationException("Unable to subscribe...");

    Console.WriteLine("Press enter to Exit...");

    Console.ReadLine();

    eventService.Unsubscribe(id);

    }

    catch (Exception ex)

    {

    Console.WriteLine(ex.ToString());

    Console.ReadLine();

    }

    }

    }

    }

    ================================================
    Compiled both the projects. Configured the webservice on the Server.
    Executed the code to subscribe to 'WorkItemChanged' Event.

    Open Team project and updated a task.

    On the server at the location Microsoft Visual Studio 2005 Enterprise Server\BISIISDIR\bisserver checked Bislog.txt
    Section of Bislog.txt is pasted below
    *********************************************************
    2005-05-26T14:56:17:49 (main) Caught exception in Send loop: System.InvalidOperationException: There was an error generating the XML document. ---> System.Net.WebException: The request was aborted: The connection was closed unexpectedly.
       at System.Net.ConnectStream.InternalWrite(Boolean async, Byte[] buffer, Int32 offset, Int32 size, AsyncCallback callback, Object state)
       at System.Net.ConnectStream.Write(Byte[] buffer, Int32 offset, Int32 size)
       at System.Xml.XmlUtf8RawTextWriter.FlushBuffer()
       at System.Xml.XmlUtf8RawTextWriter.WriteElementTextBlock(Char* pSrc, Char* pSrcEnd)
       at System.Xml.XmlUtf8RawTextWriter.WriteString(String text)
       at System.Xml.XmlWellFormedWriter.WriteString(String text)
       at System.Xml.XmlWriter.WriteElementString(String localName, String ns, String value)
       at System.Xml.Serialization.XmlSerializationWriter.WriteElementString(String localName, String ns, String value, XmlQualifiedName xsiType)
       at System.Xml.Serialization.XmlSerializationWriter.WriteElementString(String localName, String ns, String value)
       at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationWriterNotificationClient.Write1_Notify(Object[] p)
       at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Serialize(Object objectToSerialize, XmlSerializationWriter writer)
       at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
       --- End of inner exception stack trace ---
       at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle, String id)
       at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter xmlWriter, Object o, XmlSerializerNamespaces namespaces, String encodingStyle)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Serialize(SoapClientMessage message)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at Microsoft.VisualStudio.Bis.Server.Events.NotificationClient.Notify(String eventXml)
       at Microsoft.VisualStudio.Bis.Server.Events.Notification.Send(Boolean synchronous, EventHandler handler)
       at Microsoft.VisualStudio.Bis.Server.Events.Subscriber.SendQueue()
    2005-05-26T14:56:17:49 (main) Uncaught Exception.  App terminating. Object synchronization method was called from an unsynchronized block of code.

    *********************************************************
    Please can you trace where is the problem lying
    If you need any more information pl, let me know

    Thanks and Regards,
    Sonali


  • Team Build

    Great ! That did it, thanks, I was getting into this to start an automated build when check-in happens for Continuous Integration, now i just need apply this :-)
  • VSTS Extensibility, Subscription API, IEventService