Skip to main content

Posts

Showing posts from July, 2016

Transactions

1. Open the WCF service application that you created earlier or download start file here . In Service Project 2. Update the OperationContract to include a TransactionFlow attribute. This ensure a transaction is required to invoke the SubmitReview method.          [ TransactionFlow ( TransactionFlowOption .Mandatory)]         [ OperationContract ]         void SubmitReview ( ProductReview pr); 3. In the service implementation for SubmitReview, modify OperationBehavior attribute as shown below: [ OperationBehavior (TransactionScopeRequired = true , TransactionAutoComplete = true )] void IProductService .SubmitReview( ProductReview pr) 4. Add reference to System.Messaging and add  using System.Messaging; 5. In addition to writing to an XML file, lets also write to a transactional queue. First we need to create a queue. 6. Open Computer Man...

Message reliablity

When a message is sent across the network many things can go wrong. The message can be lost, dropped or sent in wrong order. This can happen due to a variety of reason, network failure, network congestion and proxy failure are few reasons among many other reasons.  WCF Reliablity features sessions are used to take care most of the above issues. There are two types of reliability Message reliability and Transport reliability. These reliability features simplifies coding needed. Enabling reliable session Reliable sessions are built on top of SOAP messaging and enables connection maintenance, verification and message ordering. Turning on reliable session allow the application to ignore duplicates, retry dropped connection and reestablish connections, notify service when the client is not available anymore. However, the cost of this reliability is increased traffic. Reliable session is easy to turn on. For some binding the reliable session is on by default whereas for ot...

Creating a user group in Windows

1. Press Windows Key > Type Computer Management 2. Click Local Users and Groups > click Groups 3. Add a New Group  4. Give a name for the group and add some users to the group as required. 5. Click Create to create the group. 

Authorization

This blog is a continuation of WCF security blog. Authorization in WCF Using Impersonation 1. Open the application that you created using WCF Security blog. 2. Let's say the application requires that the user who invokes a method is authorized to make changes to a file or write to a folder. To do this, we have to enable authorization. In the previous exercise we used the user, user2 to invoke the methods in the service. Let's now check if the user2 is authorized to write to a folder.  3. Change the SubmitReview method in Service project as given below:  void IProductService .SubmitReview( ProductReview pr) {    using ( FileStream stream = new FileStream ( "lastMessage.xml" , FileMode .Create, FileAccess .Write))    {      DataContractSerializer dcs = new DataContractSerializer ( typeof ( ProductReview ));      dcs.WriteObject(stream, pr);    }    Review...

Creating a new user in windows for testing

1. Press Windows key > select Settings > select Accounts > click  Family and other users > 2. Under Other users , click Add someone else to this PC 3. Select I don't have this person's sign-in information , and click Next. 4. Click Add user without Microsoft Account , and click Next. 5. Now fill in the required fields and click Next. 6. All done!

WCF Security

Protection Level Protection level specifies how the message is protected. The protection level can be None, signed, or Encrypted & signed. It can be specified in the [ServiceContract] and/or [OperationContract] attributes. 1. Open the WCF service application that you created earlier or download start file here . 2. You can use the protection level property to enable protection. In the service, change the ServiceContract attribute of the IProductService as given below. [ServiceContract(ProtectionLevel=System.Net.Security.ProtectionLevel.EncryptAndSign)] 3. Run the ConsoleHost project. Note: The application should throw an exception. This is because BasicHttpBinding does not support encryption and signature therefore an Exception is thrown. For this to work you need an endpoint that support encryption and signature such as netTcpBinding. 4. In ConsoleHost project, go to App.config and comment off the endpoint with basicHttpBinding 5. Add an endpoint with netTcpBindin...