European Silverlight 4 & Silverlight 5 Hosting BLOG

BLOG about Silverlight 5 Hosting and Its Techologies - Dedicated to European Windows Hosting Customer

European WCF 4.5 Hosting - Amsterdam :: IntelliSense for WCF Config file .NET 4.5

clock September 4, 2012 07:09 by author Scott

Now Visual studio 2011 is giving IntelliSense for WCF config files (App.config, Web.config). It is really good for .NET developer, previously when we developed WCF application; Application development is easy rather than configuration. Now in VS 2011 gives us IntelliSense in the Config file. Even we can also map contract.

In previous version of Visual Studio we did configuration via "
Edit WCF Configuration" wizard

In the below image we can set endpoint binding.




In the below image we can set service contract.


 



European WCF 4.0 Hosting - Amsterdam :: Creating WCF 4.0 Service and Hosting in IIS 7.5

clock May 22, 2012 11:02 by author Scott

This article will give step by step walkthrough

1. How to create a basic WCF 4.0 Service?


2. How to host WCF Service in IIS 7.5?


3. Hot to test service in a client.


Create WCF Service

Create WCF service. Open visual studio select new project and then from WCF tab select WCF Service application to create a new WCF service.




Delete the default code created by WCF from
IService1 and Service1.svc.cs

a. So delete the data contract

b. Modify the service contract as below. Just make one operation contract to return a string .

IService1.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
namespace WcfService5
{
    [ServiceContract]
    public interface IService1
    {
        [OperationContract]
        string GetMessage();

    }  

}

Service1.svc.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;

namespace WcfService5

{
    public class Service1 : IService1
    {
        public string GetMessage()
        {
            return "Hello From WCF Service ";
        }
    }
}

Leave the default configuration created by WCF.

Web.Config

<?xml version="1.0"?>
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>        
          <serviceMetadata httpGetEnabled="true"/>        
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
<system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer
</configuration>

Host WCF Service in IIS 4.0

Open IIS

a. Open the command prompt in administrator mode. To do click on Start button then type RUN in search and then in Run window type inetmgr to open IIS .



Now you will have IIS open like below




b. Right click on Sites and then click Add Web Site




c. Now a window will open




Give any name of your choice as the site name. I am giving name here
HostedWcfService



Now click on
select and choose ASP.Net v4.0 from the drop down.



Now in the physical path section, we need to give physical path of the service. So to get the physical path of the service, right click on the WCF Service project in visual studio and click open project in windows explorer. Open the project in windows explorer and from address bar copy the path and paste that below. Or you can browse also. Just click on browse button and navigate to project folder of the WCF Service.




Now at the Binding section select HTTP. Give any port number. I am selecting the port as 4567




Do not give any name as host name. Leave it blank




Check the check box Start Web Site Immediately.




And now click OK on the window.


d. Now open visual studio command prompt in administrator mode. Right click and select as administrator






Type the below command


aspnet_regiis.exe /iru



You will get the message Finished Installing ASP.Net 4.0


e. Now go to
inetmgr, you would able to see the site you just created in previous step.



Publishing the WCF Service

Go back to WCF Service. Right click and select Publish




On clicking of publish a window will come.




Give a Service URL. You are free to give any Service URL here. Just make sure host name is geeting resolved. In stead of localhost you can give IP address or your machine name also.




Give the name of the site
HostedWcfService. We created this site in previous step.



Leave the credential inactive.




Now click on
Publish.



You will get the message in bottom
publish succeeded

Browsing the service hosted in IIS


Open
Inetmgr and right click on site HostedWcfService. Then from Manage Web Site select Browse option.



When you click on browse site will get open in browser




You will get the above error. Just in address bar append Service1.svc with the address to open the service in browser.


http://localhost:4567/Service1.svc


And in browser you will get the service up and running




So now you successfully created and hosted the WCF 4.0 service in IIS 7.5


Testing the Service at client

a. Create console application project




b. Right click and add the service reference.




c. Give in address the address of service hosted in IIS and click GO.




d. Call the service as below ,


Program.cs

using
System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ConsoleApplication1.ServiceReference1;

namespace ConsoleApplication1

{
    class Program
    {
        static void Main(string[] args)
        {
            Service1Client proxy = new Service1Client();
            Console.WriteLine(proxy.GetMessage());
            Console.Read();
        }
    }
}

Output


 

 

 

 



European WCF 4.5 Hosting - Amsterdam :: WCF 4.5 Features

clock March 22, 2012 07:14 by author Scott

This post discusses the new features in WCF 4.5. There have been significant improvements in WCF 4.5 on configuration.

Simplifying the generated configuration file in client

A client configuration file is generated when you add a service reference in Visual Studio 2010. The configuration files in earlier version of WCF contained the value of every binding property even if it is a default value. In WCF 4.5 Configuration files contain binding properties that are set to non-default value.


Example of configuration file generated by WCF 3.0



Example of same configuration file generated by WCF 4.5




Single WSDL File

In earlier version of WCF, WSDL document specifies dependencies via xsd:import attributes. WSDL file generated by WCF looks as below




Some clients may not consume the above WSDL file generated from WCF earlier version. In WCF 4.5 there is a single WSDL file and no external references to schema types.


When you browse the service metadata file in WCF4.5 then you will see the below options




If you want the single WSDL file then you can use the second link which ending with ?singlewsdl


Multiple Authentication Support on single end point in IIS

Hosting the WCF Service is bit tricky. You will get an error message when your service endpoint authentication is not matching the IIS’s authentication types.




ClientCredentialType
attribute is a new feature in WCF 4.5 which tells the service to inherit the authentication types from IIS host.

Now you can enable multiple authentication types in IIS




After enabling the authentication types in IIS then if you browse service’s WSDL file then you will see the below authentication types




WebSocket Support

Two new bindings have been added to support communication over a WebSocket transport.


NetHttpBinding and NetHttpsBinding


Streaming Improvements

Support for asynchronous streaming has been added to WCF. To enable asynchronous streaming, add the DispatcherSynchronizationBehavior endpoint behavior to the service host and set its AsynchronousSendEnabled property to true. You will get the scalability benefit when service sending streamed messages to multiple clients.

In earlier versions when you host WCF service on IIS, there were some around buffering the messages. When receiving a message for IIS hosted service which used to stream a message, asp.net would buffer entire message before sending it to WCF.

Now the buffering has been removed in .NET 4.5 and now IIS hosted WCF services can process the incoming stream before the entire message has been received.

More about the features can be read here

 



About HostForLIFE.eu

HostForLIFE.eu is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2016 Hosting, ASP.NET Core 2.2.1 Hosting, ASP.NET MVC 6 Hosting and SQL 2017 Hosting.


Tag cloud

Sign in