MSDN Magazine - June 2008 - (Page 50) this contract and URI. In this scenario, the back-end system plays the role of the WCF client and broadcasts (publishes) a message to all subscribers, as illustrated here: static void DoPriceUpdate(PriceUpdate pu) { EndpointAddress ea = new EndpointAddress( "sb://connect.biztalk.net/services/contososervices/priceupdate"); ChannelFactory cf = new ChannelFactory ( new RelayBinding(RelayConnectionMode.RelayedMulticast), ea); IPriceUpdateService service = cf.CreateChannel(); service.UpdatePrice(pu); } Figure 6 Producing a Web Feed public Atom10FeedFormatter GetPriceUpdate() { SyndicationFeed feed = new SyndicationFeed("Product Update Feed", "", null); List items = new List (); feed.Items = items; IEnumerable products = GetUpdatedProducts(); string iText = "Product update for {0}. Old price={1}. New Price={2}"; foreach (var product in products) { items.Add(new SyndicationItem("Product update for " + product.Name, String.Format(iText, product.Name, product.OldUnitPrice, product.UnitPrice), null, product.Name, product.UpdatedTime)); } return new Atom10FeedFormatter(feed); } When UpdatePrice is called, the PriceUpdate message is sent to BizTalk Connectivity Services, which then relays the message to all the services currently subscribed to the same URI. Passing through Firewalls with RelayedHttp RelayedHttp mode enables you to take an HTTP service running on your local network and expose it through BizTalk Connectivity Services via HTTP on the public Web, even if that service would not normally be directly accessible from outside your network. This feature is especially handy when used in conjunction with the new WCF Web programming model found in the .NET Framework 3.5. This new Web programming model makes it easier to implement RESTful Web services with WCF. It also provides features that make it easy to integrate your WCF services with existing RSS/Atom and AJAX infrastructure found on the Web today. BizTalk Services doesn’t require the .NET Framework 3.5, but given these new WCF features, RelayedHttp mode has more functionality when you have the .NET Framework 3.5 installed. Going back to the sales application, sometimes salespeople are not running the rich client application, but they still need to be notified of the latest pricing information. One interesting way to expose data that is updated often is through a Web feed—an HTTP endpoint that returns well-known XML formats, such as RSS or Atom, to applications that know how to consume those feeds. Web feeds can be polled for new content on a set schedule by a feed reader (the common name for a program that aggregates Web feeds into a human-facing UI). This enables the end user to receive updates without actively navigating to the site but rather by looking at his feed reader. Using the WCF Web programming model, we can easily build a Web feed that exposes the price update data. The first thing we need is a contract that uses the new WCF attributes for enabling HTTP invocations. These attributes inform the WCF messaging layer how to route incoming HTTP requests to the methods on the service based on the URI rather than the SOAP Action header. Here’s an example: [ServiceContract] public interface IPriceUpdateFeed { [OperationContract()] [WebGet(UriTemplate = "*")] Atom10FeedFormatter GetPriceUpdate(); } Also note the UriTemplate property on WebGetAttribute. This tells WCF exactly how to route incoming messages to different methods based on the URI of the incoming request. This example uses a wildcard template (“*”) to indicate that we want all GET requests routed to this particular method. You could easily configure multiple methods on a service, each of which handles a different UriTemplate. There’s also a WebInvokeAttribute that you can use when you want to respond to other HTTP verbs besides GET (including POST, PUT, DELETE, and HEAD). The other thing to notice about this contract is the method’s return type. The WCF Web programming model includes new types specifically designed to help produce today’s standard feed formats. The two major formats supported today are Atom and RSS. The example here uses the Atom format. WCF 3.5 comes with a new binding class that makes configuring endpoints easy. Figure 6 shows a simple implementation of the GetPriceUpdate operation that produces an Atom syndication feed. This implementation uses the new SyndicationFeed API for producing a logical feed, which it returns wrapped in an Atom10FeedFormatter object in order to produce the correct XML format. Now we need to configure an endpoint to listen for these requests. WCF 3.5 comes with a new binding class to make configuring the endpoint very easy. The WebHttpBinding class encapsulates the details around creating a RESTful channel stack that won’t expect SOAP messages. It simply uses the HTTP transport and the textbased message encoder from WCF, with the message version of the encoder set to None. Here is the code required to get our new endpoint hooked up and running: ServiceEndpoint se = sh.AddServiceEndpoint(typeof(IPriceUpdateFeed), new WebHttpBinding(), "http://localhost:8099/ProductFeed"); se.Behaviors.Add(new WebHttpBehavior()); Here WebGetAttribute tells WCF that this method should be called whenever an HTTP GET request arrives at the service (in contrast to SOAP requests, which always use HTTP POST). 50 msdn magazine BizTalk Services
Table of Contents Feed for the Digital Edition of MSDN Magazine - June 2008 MSDN Magazine - June 2008 Contents Toolbox CLR Inside Out Cutting Edge Patterns In Practice SAAS Concurrency Robotics Form Filler GUI Library Service Station Foundations Windows With C++ Concurrent Affairs Going Places { End Bracket } MSDN Magazine - June 2008 MSDN Magazine - June 2008 - Contents (Page Cover1) MSDN Magazine - June 2008 - Contents (Page Cover2) MSDN Magazine - June 2008 - Contents (Page 1) MSDN Magazine - June 2008 - Contents (Page 2) MSDN Magazine - June 2008 - Contents (Page 3) MSDN Magazine - June 2008 - Contents (Page 4) MSDN Magazine - June 2008 - Contents (Page 5) MSDN Magazine - June 2008 - Contents (Page 6) MSDN Magazine - June 2008 - Contents (Page 7) MSDN Magazine - June 2008 - Contents (Page 8) MSDN Magazine - June 2008 - Contents (Page 9) MSDN Magazine - June 2008 - Contents (Page 10) MSDN Magazine - June 2008 - Toolbox (Page 11) MSDN Magazine - June 2008 - Toolbox (Page 12) MSDN Magazine - June 2008 - Toolbox (Page 13) MSDN Magazine - June 2008 - Toolbox (Page 14) MSDN Magazine - June 2008 - CLR Inside Out (Page 15) MSDN Magazine - June 2008 - CLR Inside Out (Page 16) MSDN Magazine - June 2008 - CLR Inside Out (Page 17) MSDN Magazine - June 2008 - CLR Inside Out (Page 18) MSDN Magazine - June 2008 - CLR Inside Out (Page 19) MSDN Magazine - June 2008 - CLR Inside Out (Page 20) MSDN Magazine - June 2008 - CLR Inside Out (Page 21) MSDN Magazine - June 2008 - CLR Inside Out (Page 22) MSDN Magazine - June 2008 - CLR Inside Out (Page 23) MSDN Magazine - June 2008 - CLR Inside Out (Page 24) MSDN Magazine - June 2008 - Cutting Edge (Page 25) MSDN Magazine - June 2008 - Cutting Edge (Page 26) MSDN Magazine - June 2008 - Cutting Edge (Page 27) MSDN Magazine - June 2008 - Cutting Edge (Page 28) MSDN Magazine - June 2008 - Cutting Edge (Page 29) MSDN Magazine - June 2008 - Cutting Edge (Page 30) MSDN Magazine - June 2008 - Cutting Edge (Page 31) MSDN Magazine - June 2008 - Cutting Edge (Page 32) MSDN Magazine - June 2008 - Cutting Edge (Page 33) MSDN Magazine - June 2008 - Cutting Edge (Page 34) MSDN Magazine - June 2008 - Cutting Edge (Page 35) MSDN Magazine - June 2008 - Cutting Edge (Page 36) MSDN Magazine - June 2008 - Patterns In Practice (Page 37) MSDN Magazine - June 2008 - Patterns In Practice (Page 38) MSDN Magazine - June 2008 - Patterns In Practice (Page 39) MSDN Magazine - June 2008 - Patterns In Practice (Page 40) MSDN Magazine - June 2008 - Patterns In Practice (Page 41) MSDN Magazine - June 2008 - Patterns In Practice (Page 42) MSDN Magazine - June 2008 - Patterns In Practice (Page 43) MSDN Magazine - June 2008 - SAAS (Page 44) MSDN Magazine - June 2008 - SAAS (Page 45) MSDN Magazine - June 2008 - SAAS (Page 46) MSDN Magazine - June 2008 - SAAS (Page 47) MSDN Magazine - June 2008 - SAAS (Page 48) MSDN Magazine - June 2008 - SAAS (Page 49) MSDN Magazine - June 2008 - SAAS (Page 50) MSDN Magazine - June 2008 - SAAS (Page 51) MSDN Magazine - June 2008 - SAAS (Page 52) MSDN Magazine - June 2008 - SAAS (Page 53) MSDN Magazine - June 2008 - Concurrency (Page 54) MSDN Magazine - June 2008 - Concurrency (Page 55) MSDN Magazine - June 2008 - Concurrency (Page 56) MSDN Magazine - June 2008 - Concurrency (Page 57) MSDN Magazine - June 2008 - Concurrency (Page 58) MSDN Magazine - June 2008 - Concurrency (Page 59) MSDN Magazine - June 2008 - Concurrency (Page 60) MSDN Magazine - June 2008 - Concurrency (Page 61) MSDN Magazine - June 2008 - Concurrency (Page 62) MSDN Magazine - June 2008 - Concurrency (Page 63) MSDN Magazine - June 2008 - Robotics (Page 64) MSDN Magazine - June 2008 - Robotics (Page 65) MSDN Magazine - June 2008 - Robotics (Page 66) MSDN Magazine - June 2008 - Robotics (Page 67) MSDN Magazine - June 2008 - Robotics (Page 68) MSDN Magazine - June 2008 - Robotics (Page 69) MSDN Magazine - June 2008 - Robotics (Page 70) MSDN Magazine - June 2008 - Robotics (Page 71) MSDN Magazine - June 2008 - Robotics (Page 72) MSDN Magazine - June 2008 - Robotics (Page 73) MSDN Magazine - June 2008 - Robotics (Page 74) MSDN Magazine - June 2008 - Robotics (Page 75) MSDN Magazine - June 2008 - Robotics (Page 76) MSDN Magazine - June 2008 - Robotics (Page 77) MSDN Magazine - June 2008 - Robotics (Page 78) MSDN Magazine - June 2008 - Form Filler (Page 79) MSDN Magazine - June 2008 - Form Filler (Page 80) MSDN Magazine - June 2008 - Form Filler (Page 81) MSDN Magazine - June 2008 - Form Filler (Page 82) MSDN Magazine - June 2008 - Form Filler (Page 83) MSDN Magazine - June 2008 - Form Filler (Page 84) MSDN Magazine - June 2008 - Form Filler (Page 85) MSDN Magazine - June 2008 - GUI Library (Page 86) MSDN Magazine - June 2008 - GUI Library (Page 87) MSDN Magazine - June 2008 - GUI Library (Page 88) MSDN Magazine - June 2008 - GUI Library (Page 89) MSDN Magazine - June 2008 - GUI Library (Page 90) MSDN Magazine - June 2008 - GUI Library (Page 91) MSDN Magazine - June 2008 - GUI Library (Page 92) MSDN Magazine - June 2008 - GUI Library (Page 93) MSDN Magazine - June 2008 - GUI Library (Page 94) MSDN Magazine - June 2008 - GUI Library (Page 95) MSDN Magazine - June 2008 - GUI Library (Page 96) MSDN Magazine - June 2008 - Service Station (Page 97) MSDN Magazine - June 2008 - Service Station (Page 98) MSDN Magazine - June 2008 - Service Station (Page 99) MSDN Magazine - June 2008 - Service Station (Page 100) MSDN Magazine - June 2008 - Service Station (Page 101) MSDN Magazine - June 2008 - Service Station (Page 102) MSDN Magazine - June 2008 - Service Station (Page 103) MSDN Magazine - June 2008 - Service Station (Page 104) MSDN Magazine - June 2008 - Foundations (Page 105) MSDN Magazine - June 2008 - Foundations (Page 106) MSDN Magazine - June 2008 - Foundations (Page 107) MSDN Magazine - June 2008 - Foundations (Page 108) MSDN Magazine - June 2008 - Foundations (Page 109) MSDN Magazine - June 2008 - Foundations (Page 110) MSDN Magazine - June 2008 - Foundations (Page 111) MSDN Magazine - June 2008 - Foundations (Page 112) MSDN Magazine - June 2008 - Windows With C++ (Page 113) MSDN Magazine - June 2008 - Windows With C++ (Page 114) MSDN Magazine - June 2008 - Windows With C++ (Page 115) MSDN Magazine - June 2008 - Windows With C++ (Page 116) MSDN Magazine - June 2008 - Windows With C++ (Page 117) MSDN Magazine - June 2008 - Windows With C++ (Page 118) MSDN Magazine - June 2008 - Concurrent Affairs (Page 119) MSDN Magazine - June 2008 - Concurrent Affairs (Page 120) MSDN Magazine - June 2008 - Concurrent Affairs (Page 121) MSDN Magazine - June 2008 - Concurrent Affairs (Page 122) MSDN Magazine - June 2008 - Concurrent Affairs (Page 123) MSDN Magazine - June 2008 - Concurrent Affairs (Page 124) MSDN Magazine - June 2008 - Concurrent Affairs (Page 125) MSDN Magazine - June 2008 - Concurrent Affairs (Page 126) MSDN Magazine - June 2008 - Going Places (Page 127) MSDN Magazine - June 2008 - Going Places (Page 128) MSDN Magazine - June 2008 - Going Places (Page 129) MSDN Magazine - June 2008 - Going Places (Page 130) MSDN Magazine - June 2008 - Going Places (Page 131) MSDN Magazine - June 2008 - { End Bracket } (Page 132) MSDN Magazine - June 2008 - { End Bracket } (Page Cover3) MSDN Magazine - June 2008 - { End Bracket } (Page Cover4)
For optimal viewing of this digital publication, please enable JavaScript and then refresh the page. If you would like to try to load the digital publication without using Flash Player detection, please click here.