WS-Eventing Part III: The Notification Message



Ok, now pay close attention; this part gets real complicated.  The required elements of a notification message (that is, the shark-attack message sent to the subscriber) are as follows:



That’s right, there are no required elements.  Any SOAP message can be a valid notification.  The event source and the event sink (aka the subscriber) must agree on the notification format, and the WS-Eventing spec doesn’t mandate how that agreement is achieved.  A couple options occur to me off the top of my head.  Documentation can specify the format, and both sides can simply use the same documented format for the message.  Alternatively, the format could be published via WSDL at the event source, which the subscriber could use to process the notification message or generate a proxy for it.  (Or would that be a stub?)


If the subscriber really needs to know which subscription a particular notification is associated with, that subscriber can attach a tag to the subscription request.  That tag will then be included in all notification messages the event source sends to that subscriber.  The tag looks like this:



<Envelope>


    <Header>


        <Action>http://schemas.xmlsoap.org/ws/2004/01/eventing/Subscribe</Action>


        <MessageID>http://www.me.com/subscriptions/583</MessageID>


        <ReplyTo>http://www.me.com/subscription-response-handler</ReplyTo>


        <To>http://www.ocean.com/notifications/shark-attacks</To>


    </Header>


    <Body>


        <Subscribe>


            <NotifyTo>


                <Address>http://www.me.com/shark-attack-notification-handler</Address>


                <ReferenceProperties>


                    <MyCustomHeader>This is from my shark-attack subscription!</MyCustomHeader>


                </ReferenceProperties>


            </NotifyTo>


        </Subscribe>


    </Body>


</Envelope>


This will force the event source to add that tag as a header to every notification that it sends to that subscriber, like so:



<Envelope>


    <Header>


        <To> http://www.me.com/shark-attack-notification-handler</To>


        <MyCustomHeader>This is from my shark-attack subscription!</MyCustomHeader>


    </Header>


    <Body>


        <SharkAttackInfo>


           <Location>Daytona Beach</Location>


           <NumberOfStitches>184</NumberOfStitches>


        </Subscribe>


    </Body>


</Envelope>

Comments (10)

  1. Mike J says:

    is publishing with "MyCustomHeader" tag actually required by WS-E or one of the things that occur to you?

    Thanks. Great job.

  2. Mike, I made up the element name; it could be anything, and does not need to be specified. If the subscriber does include any elements inside the <ReferenceProperties> of the subscription, however, the event source MUST echo them back inside each notification to that subscriber.

  3. Mike J says:

    Sweet. Thanks. BTW, did you remember to color code all of the places where data gets forwarded from the subscription to the response? I’m using RSSBandit and most of the text is still black, except that which is blue.

  4. My pleasure; I love feedback! When I look at "Part II" I see some stuff highlighted in blue, green, and yellow. If you aren’t seeing that, then RSSBandit is probably stripping that formatting off.

  5. Matt says:

    I am trying to figure out how to define the web service that receives the different eventing messages. Are there any samples around in C# or VB.NET that defines a simple subscription web service method?

    I have found how to add the SOAP header but I really want to see how all the namespaces are added into the web service so the WSDL is correct.

    Thanks.