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: 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

Creating an OData Service for a SQL Server Database

To create an OData service for a SQL Server database, we will create a new Visual Studio ASP.NET web application: Select Empty template and check Web API: This will create: Now, add the OData NuGet packages: Add Entity Framework: Next, add a new item: Select EF Designer from database: Select the database connection, click new connection if required, and click Next. We will connect to an Azure SQL database with … Continue reading Creating an OData Service for a SQL Server Database

Introduction to Web Services

Introduction Web Services are defined as a machine to machine interaction that takes place over the world wide web. Applications and servers expose functionality and data that allows other machines to communicate with them, often through standards that have been agreed upon by organizations, corporations and the community. Previously, there had been many attempts to allow different applications to be able to talk to each other, especially for business. DCOM, EDI, CORBA … Continue reading Introduction to Web Services