Building a Pub/Sub Message Bus with WCF and MSMQ
In my previous blog I demonstrate how to build a offline distributed system with MSMQ. In this blog I will show you how to build a Publish/Subscribe message bus using WCF and MSMQ. The solution is built with .NET Framework 3.0 and makes extensive use of Windows Communication Foundation (WCF), Microsoft Message Queuing (MSMQ) 4.0 and Internet Information Services (IIS) 7.0, all hosted on Windows Server 2008. Now follow me.1. Defining the Service ContractThe first step was to define the contracts
Push Data From Server to Silverlight Clients With a WCF Duplex Service
Normally in a client-server architecture application, the client makes a request to the server, then the server responses to the client. The client side PULLs data from the server side. However, we sometimes want the server side to PUSH data to the client side whenever the data changed. With a WCF duplex service, we can push updated data to Silverlight clients. In the rest of this blog I will show you how to achieve this goal.Many of the WCF services out there follow the simple request-response
Reading message from nontranscational remote MSMQ in workgroup
MSMQ is very useful for building a distributed, offline application. In my recent project the customer requires reading message remotely from a MSMQ queue. In this blog I will show you the solution.1. MSMQ API Get StartedAccessing MSMQAccessing a queue via .NET is done with the System.Messaging.MessageQueue object. The following code demonstrates how to access a public queue named TechRepublic on a computer named "SRV-MESSAGING":MessageQueue queue = new MessageQueue("SRV-MESSAGING
WCF Services Sample: Authenticate Silverlight Client based on Custom Security Token
In my blog "WCF Services Sample: Authenticate Silverlight Client based on UserName and Password", I show you how to improve security of WCF security by using a custom validator to authenticate Silverlight client based on username and password. That solution look good. However, it is not a final solution. You know, the Silverlight application runs on local machine of the remote users. The Silverlight communicate with WCF service via BasicHttpBinding, which transfer messages in cleratext
WCF Extension : Inject and Inspect Custom Message
While working with WCF, we often need transfer some kind of data in message headers. For example, in order to authenticate the caller of WCF service, we need pass username and password into the message header, then in the service side retrieve them and validate them. But how can we inject a custom message on WCF client side and retrieve it on WCF service side? The key is System.ServiceModel.Dispatcher.IClientMessageInspector and System.ServiceModel.Dispatcher.IDispatchMessageInspector. To learn
WCF Services Sample: Authenticate Silverlight Client based on UserName and Password
In the <<WCF Sevices Sample>> series, I have gone through WCF service creation, hosting, transport protocol supporting. By now our service can be accessed by anyone from anywhere, because we did not authenticate the service caller. The Windows Communication Foundation (WCF) provides many choice for us on service security. For more information about this subject, please refer to MSDN.In this blog I'd like to talk about WCF service authentication based on username and password. I'd lik
WCF Services Sample: Config WCF services over HTTPS only
In my previous blogs I have introduced how to create a WCF service and host it in IIS, and config it over both Http and Https. In this blog I would like to move forward -- config the service work over only HTTPS. I will still use that sample project.1. Setup Web Application with SSL RequiredOpen the IIS Manager, Select "ServiceHost" web application under the default web site as shown below.Double-click "SSL Settings" on the right frame, the "SSL Settings" window is
WCF Services Sample:Config over both HTTP and HTTPS
In my blog "WCF Services Sample: create a Silverlight client application", I show you how to config WCF service and Silverlight to communicate over HTTP. In this blog I will introduce how to config WCF service over both HTTP and HTTPS. I still use that sample project in this blog.1. Setup IIS to Enable SSLBefore WCF service can work over HTTPS, we must setup IIS to enable SSL. I have talked about this subject in my another blog, please refer to it for more details.2. WCF Service Config
WCF Services Sample: create a Silverlight client application
In my previous blog, I created a WCF service and hosted it in IIS. In this blog I will create a Silverlight client application to call that service, and host the Silverlight client in a ASP.Net web application.1. Create a Silverlight ApplicationRight click the solution in the Solution Explorer, Add -> New Project. In the window below, select "Silverlight" as Project Type, select "Silverlight Application" Template, input project Name and Location, then click "OK".
WCF Services Sample: Create and Host a Service in IIS
In this blog I will show you how to create and host a WCF services from scratch.1. Define the Services ContractOpen Visual Studio 2008, File -> New -> Project. It will open the "New Project" window for you. Select "Web" under the "Visual C#" on the left treeview "Project types", then select "WCF Service Application" under the "Templates" on the right side window. Input the project Name and Location,check "Create dictionary fo
WCF Essentials (5)
11. WCF ArchitectureWCF offers immensely valuable support for reliability, transactions, concurrency management, security, and instance activation, all of which rely on the WCF interception-based architecture. Having the client interact with a proxy means that WCF is always present between the service and the client, intercepting the call and performing pre- and post-call processing. The interception starts when the proxy serializes the call stack frame to a message and sends the message down a
WCF Essentials (4)
9. EndpointsEvery service is associated with an address that defines where the service is, a binding that defines how to communicate with the service, and a contract that defines what the service does. This triumvirate governing the service is easy to remember as the ABC of the service. WCF formalizes this relationship in the form of an endpoint. The endpoint is the fusion of the address, contract, and binding.Every endpoint must have all three elements, and the host exposes the endpoint. Logica
WCF Essentials (3)
8. BindingsThere are multiple aspects of communication with any given service, and there are many possible communication patterns: messages can be synchronous request/reply or asynchronous fire-and-forget; messages can be bidirectional; messages can be delivered immediately or queued; and the queues can be durable or volatile. There are many possible transport protocols for the messages, such as HTTP (or HTTPS), TCP, P2P (peer network), IPC (named pipes), or MSMQ. There are a few possible messag
WCF Essentials (2)
5. AddressesIn WCF, every service is associated with a unique address. The address provides two important elements: the location of the service and the transport protocol or transport schema used to communicate with the service. The location portion of the address indicates the name of the target machine, site, or network; a communication port, pipe, or queue; and an optional specific path or URI. A URI is a Universal Resource Identifier, and can be any unique string, such as the service name or
WCF Essentials (1)
1. What Is WCF?Windows Communication Foundation (WCF) is an SDK for developing and deploying services on Windows. WCF provides a runtime environment for your services, enabling you to expose CLR types as services, and to consume other services as CLR types.WCF is Microsoft's implementation of a set of industry standards defining service interactions, type conversion, marshaling, and various protocols' management. The first release of WCF provides many useful facilities for developing services, s
WCF Security:Silverlight authentication for WCF service based on security token
In my previous blogs I show you how to authenticate WCF service client base on username/password. That is very available for ASP.Net client. But with Silverlight client, it is not available. THe Silverlight application is running on the remote machine of end users, it is not acceptable to transfer usename/password in cleartext in the wire. In addition, Silverlight supports BasicHttpBinding only,so security in transport level is not supported. In order to authenticate Silverlight calle
WCF Security:authentication base on Username/Password - Part III
1. By now ,we know how to config our WCF webservice and client so that it can work base on Usename authentication,with either basicHttpBinding or wsHttpBinding. Note the security mode. Using Transport only would leave us no options for a custom username / password scenario; basic and digest both don’t play nice with WCF's custom username / password mechanism. Ideal would be Message security, but the combination of Message security and basicHttpBinding doesn’t support a username / pas
WCF Security:authentication based on Username/Password - Part II
Error Message Could not find a base address that matches scheme http for the endpoint with binding MetadataExchangeHttpBinding. Registered base address schemes are [https]. Incorrect Config <behaviors> <serviceBehaviors> <behavior name="DataDistribution.ServiceImplementation.DataDistributionService_Behavior"> <serviceDebug includeExceptionDetailInFaults="true" /> <serviceMetadata httpGetEnabled="true" /> &l
WCF Security:authentication based on Username/Password - Part I
Goals: To enhancement security of WCF webservice, we need to authenticate the client of our WCF webservice. In the case of Sentry Project, we choose to authenticate the client of WCF webservice base on username/password,via a custom UserNamePasswordValidator type. We need a Declarative mode by setting configurations of WCF and the client. Questions: While researching, I encountered the following troubles: 1. While chosen “Username” option with Message Security, WCF limits the us
Understanding Windows Communication Foundation Extensibility
Summary: Provides a detail about the extensibility mechanisms existing in WCF. This paper covers each extensibility point in detail and, more importantly, when to use which one. This article assumes basic knowledge of WCF and it’s concepts. Windows® Communication Foundation (WCF) is the new unified communication programming model for building service-oriented applications. It’s one of the three pillars of the NET 3.0 platform that’s part of the new Windows® Vista operating