Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Introducing Windows Azure- P39:The cloud platform is getting more and more attractive to the computing world. Today, service-oriented architecture (SOA) and aspect-oriented programming (AOP) techniques are widely used in enterprise solutions. A question an IT management team or a software development team may ask is, what is the next trend going to be? Cloud computing seems to be the right answer. | CHAPTER 6 AZURE .NET SERVICES SERVICE BUS 3. Create a service host class. The format to compose an address of .NET Service Bus is the following where optional required. sb http https solution .servicebus.windows.net service topic sub topic The endpoint address to be used in this exercise is sb softnetsolutionsservicebus.servicebus.windows.net Pheonix RelayService 4. Listing 6-3 shows the implementation for the host class. This class declares two constructors. The second constructor takes the endpoint URI as a parameter. This allows the host to be able to accept different endpoints in order to support multiple modes for the .NET relay connection. As you can see we use a username and password to authenticate in this example. The class constructor of the service host accepts four parameters that will be passed in when the host instance is instantiated. The first parameter is a generic type parameter of the WCF service implementation class not the service contract interface type and the other three parameters are account-related parameters solutionName password and topic. The topic parameter is used to construct the URI address as a lower-level hierarchy in case there are multiple service hosts registered under the same solution and we can get all URI addresses that are globally unique. The remaining part of the host implementation is pretty straightforward. We use the URI address to instantiate a ChannelFactory instance the ChannelFactory class can accept the WCF interface type IRelayPublishEventService which is derived from both the custom-defined WCF service interface and the IClientChannel interface defined from the System.ServiceModel namespace . We then call the CreateChannel and Open methods sequentially to start the service request listener on the host side from the cloud. Listing 6-3. Implementation ofthe Host Class using System using System.Collections.Generic using System.Linq using System.Text using System.Security.Cryptography using System.ServiceModel .