Introduction to OAuth

OAuth is an open standard for authorization of websites and applications. It provides these applications with a simple, secure way allow their users to access their data. For example, let’s say you are a developer building an application. OAuth allows you to delegate the authorization. There are many websites and mobile applications that use Facebook or Google to authentication users. This is done through OAuth. OAuth has many benefits. The framework does … Continue reading Introduction to OAuth

Using the Postman REST Client

The Postman REST client is a client application that has a Chrome extension. Here we will go into how to install and use the client. Go to the Chrome web store: https://chrome.google.com/webstore/category/extensions?hl=en Search for Postman. You will see this app below. Click Add To Chrome: You will see this Postman link below: This will open the page: And after that: Enter a REST URI, e.g. https://www.googleapis.com/books/v1/volumes?q=isbn:0747532699 The response is returned: You can change the … Continue reading Using the Postman REST Client

Publish Web Service to Azure from Visual Studio

To publish a web service from Visual Studio, do the following. You may need to install the Azure SDK for .NET. You can find the download link on the Microsoft website: https://azure.microsoft.com/en-us/downloads/archive-net-downloads/ Select the web service. Right click and publish:   Select Microsoft Azure App Service and New: Confirm the details and click Create: Press Publish: A webpage will be created with the instructions: And you can access the web service … Continue reading Publish Web Service to Azure from Visual Studio

XMLHttpRequest Explained

The XMLHttpRequest is an API used in modern web browsers. It contains methods that allow communication between the web browser and a web server through JavaScript. Although the name is XML, it can also support JSON. Let’s go through an example of how to use it. First, we will use a previous example where we have a WCF web service set up. This service is then uploaded to Azure so it can be … Continue reading XMLHttpRequest Explained

Create WCF Web Service in Visual Studio

Windows Communication Foundation (WCF) web services can be created in Visual Studio. Note these web services replace the old asmx web services. To create a web service in Visual Studio do the following. Create a new project in Visual Studio and select WCF Service Application: This creates the solution: Delete the existing Service1.svc and IService1.cs and add a new WCF Service: This will create these 2 files again. Note the … Continue reading Create WCF Web Service in Visual Studio

WCF Service Tcp Binding Example

In this post we will take a look at using tcp bindings in a WCF service. We will follow on from a previous post example. In our previous example, we have a WCF host that is using basicHttpBindings: Clicking Edit, we can see the different bindings available: Let’s add a new TCP binding to our app. Select New Service Endpoint: Select netTcpBinding: Add the address and contract: Save the config. … Continue reading WCF Service Tcp Binding Example

Self-Hosting a WCF Service in a Windows Console App

WCF Services can be self-hosted in a Windows console app. Here we will go through how to do this. First, create a new class library project in Visual Studio: Add a new item: Add a new WCF Service: Add some code to GetData in IService.cs: And Service1.cs: Delete any configuration files that are part of the project. We will use the configuration in our calling app. Compile the code. Now, … Continue reading Self-Hosting a WCF Service in a Windows Console App

WCF Fault Exception

In this example, we will show how to use the FaultException when catching errors in a WCF service. First, create a new WCF service: Our service will be a calculator, that will perform a divide operation. We will rename the files created so we have: Calculator.svc ICalculator.cs In ICalculator, change the code to be below. This is our service contract and operation contract: using System; using System.Collections.Generic; using System.Linq; using … Continue reading WCF Fault Exception

WCF Specify Names of Contracts

Consider a WCF service that returns some text that you entered. The service has a contract called IService1 and an operation called GetData. When we run the service in our test client, we see: The code for this is: using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.ServiceModel; using System.ServiceModel.Web; using System.Text; namespace Carl.TestWCF { [ServiceContract] public interface IService1 { [OperationContract] string GetData(int value); } } Let’s say we … Continue reading WCF Specify Names of Contracts

Using Fiddler with Web API

In this post, we will examine using Fiddler to send requests and receive responses from an ASP.NET Web API. I have a Web API sample that looks like the following: There are different HTTP verbs, including: GET PUT POST DELETE The Customers API is very simple – it integrates with a SQL Server table called Customers with 2 fields – CustomerId and CustomerName, with the data: Start Fiddler. We will … Continue reading Using Fiddler with Web API