The metadata is to describe how to interact with the service's endpoints. We could generate Proxy class for the Client as well as it updates the .config files[App.config/Web.config] for the Client Application.
For example Svcutil.exe could automatically generated client code for accessing the service..
Trough Visual Studio 2008/2005 with WCF extension, we can "Add Service Reference" which does the entire necessary task for us.

For is purpose it is the following code added to the Service Code.

using System.ServiceModel.Description;

ServiceMetadataBehavior svcMetaBehav = new ServiceMetadataBehavior();
svcMetaBehav.HttpGetEnabled = true;
svcHost.Description.Behaviors.Add(svcMetaBehav);

 

 

The WSDL of this service looks like as following:
  

WSDL of WCF Service

WSDL - WCF

<wsdl:binding name="BasicHttpBinding_IMyFirstService" type="i0:IMyFirstService">
  <soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="MyFirstMethod">
  <soap:operation soapAction="http://KolkataNET.WCF.HOL/IMyFirstService/MyFirstMethod" style="document" />
 <wsdl:input>
  <soap:body use="literal" />
  </wsdl:input>
<wsdl:output>
  <soap:body use="literal" />
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
 
 
 <wsdl:service name="MyFirstService">
 <wsdl:port name="BasicHttpBinding_IMyFirstService" binding="tns:BasicHttpBinding_IMyFirstService">
  <soap:address location="http://abu:8080/WCFKolkataNET/HOL/MyService" />
  </wsdl:port>
  </wsdl:service>
 

 

Posted by abu | with no comments

Step 5. Create New Console Project for creating Client Application the Service - Start running the Service when you generate the Proxy of the Service

 

5.1- Added Service Reference of the created Service

5.2- Created Proxy Class of the created Service - In service explorer click on show all files then a set of files will be showing which are auto generated, the proxy class file is here Reference.cs

 

 5.3 This also generates the service binding details in App.config file

 

 5.3 Auto generated Binding Details of the service in App.config file

 

    <bindings>

      <basicHttpBinding>

        <binding name="BasicHttpBinding_IMyFirstService" closeTimeout="00:01:00"

          openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"

          allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"

          maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"

          messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"

          useDefaultWebProxy="true">

          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"

            maxBytesPerRead="4096" maxNameTableCharCount="16384" />

          <security mode="None">

            <transport clientCredentialType="None" proxyCredentialType="None"

              realm="" />

            <message clientCredentialType="UserName" algorithmSuite="Default" />

          </security>

        </binding>

      </basicHttpBinding>

    </bindings>

 

5.3 Auto generated End Point of the service in App.config file

 

    <client>

      <endpoint address="http://abu:8080/WCFKolkataNET/HOL/MyService" binding="basicHttpBinding"

        bindingConfiguration="BasicHttpBinding_IMyFirstService" contract="MyFirstServiceClient.IMyFirstService"

        name="BasicHttpBinding_IMyFirstService" />

    </client>

5.4 Code in Prorgarm.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Runtime.Serialization;

using System.ServiceModel;

 

namespace KolkataNETWCFHelloWorld

{

    class Program

    {

        static void Main(string[] args)

        {

            EndpointAddress endPointAddr = new EndpointAddress("http://abu:8080/WCFKolkataNET/HOL/MyService");

            MyFirstServiceClient clientProxy = new MyFirstServiceClient(new BasicHttpBinding(), endPointAddr);

            string strResponse = clientProxy.MyFirstMethod();

 

            Console.WriteLine(string.Format("Response from MyFirstService: {0}", strResponse));

            Console.WriteLine();

            Console.ReadLine();

        }

    }

}

 Run the Client Application

 

Posted by abu | with no comments
Filed under:

Step 1. Created one Console Project

 

Step 2. Created one Project in the same Solution IMyFirstService.csproj for declaring/designing Service contact

 

2.1- Added reference to System.ServiceModel

using System;

using System.Runtime.Serialization;

using System.ServiceModel;

 

namespace KolkataNETWCFHelloWorld

{

    [ServiceContract(Namespace="http://KolkataNET.WCF.HOL")]

    public interface IMyFirstService

    {

        [OperationContract]

        string MyFirstMethod();

    }

}

2.2 Design Simple Service Contract with one

    [ServiceContract(Namespace="http://KolkataNET.WCF.HOL")]

    public interface IMyFirstService

 

2.3 Design Simple Operation [Method/Function] using Attribute [OperationContract] by declaring the method name MyFirstMethod

 

Step 3. Created one Project in the same Solution MyFirstService.csproj for declaring/designing Service

 

3.1- Added reference to System.ServiceModel

using System;

using System.Runtime.Serialization;

using System.ServiceModel;

 

namespace KolkataNETWCFHelloWorld

{

    public class MyFirstService : IMyFirstService

    {

        public string MyFirstMethod()

        {

            return string.Format("Hello World. Welcome KolkataNET!!!");

        }

    }

}

3.2 Design Simple Service implementing the above service Contract

    public class MyFirstService : IMyFirstService

 

3.3 Design Simple Operation [Method/Function]

    public class MyFirstService : IMyFirstService

    {

        public string MyFirstMethod()

        {

            return string.Format("Hello World. Welcome KolkataNET!!!");

        }

    }

 

Step 4. Modified the initial main Console Project to Self Host the Service

 

4.1- Added reference to System.ServiceModel - For hosting the service and exposing MEX - Metadata Exchange of the Service

using System;

using System.Runtime.Serialization;

using System.ServiceModel;

using System.ServiceModel.Description;

 

namespace KolkataNETWCFHelloWorld

{

    class Program

    {

        static void Main(string[] args)

        {

            Uri svcBaseAddress = new Uri("http://abu:8080/WCFKolkataNET/HOL");

            ServiceHost svcHost = new ServiceHost(typeof(MyFirstService), svcBaseAddress);

            svcHost.AddServiceEndpoint(

                               typeof(IMyFirstService),

                               new BasicHttpBinding(),

                               "MyService");

            ServiceMetadataBehavior svcMetaBehav = new ServiceMetadataBehavior();

            svcMetaBehav.HttpGetEnabled = true;

            svcHost.Description.Behaviors.Add(svcMetaBehav);

            svcHost.Open();

            Console.WriteLine("<ENTER> to stop the service - MyFirstService");

            Console.WriteLine();

            Console.ReadLine();

            svcHost.Close();

        }

    }

}

4.2 Defining Base Address to host the Service

Uri svcBaseAddress = new Uri("http://abu:8080/WCFKolkataNET/HOL");

            ServiceHost svcHost = new ServiceHost(typeof(MyFirstService), svcBaseAddress);

            svcHost.AddServiceEndpoint(

                               typeof(IMyFirstService),

                               new BasicHttpBinding(),

                               "MyService");

 

4.3 Allowing to expose MEX of the Service

            ServiceMetadataBehavior svcMetaBehav = new ServiceMetadataBehavior();

            svcMetaBehav.HttpGetEnabled = true;

            svcHost.Description.Behaviors.Add(svcMetaBehav);

 

4.3 Running the service until <ENTER> key has been pressed

svcHost.Open();

 

4.4 Closing the service when <ENTER> key has been pressed

svcHost.Close();

 

Running the Service - now we will create client to call it

 

Posted by abu | with no comments
Filed under:

Here is the code...

Click to Download

This is my first post for WCF HOL. I will be posting series of Lab Sessions with code and explanations for the whole series. I have noticed in one UG Session people who don't have any WCF backround but who are familiars of ASP.NET/.NET for them this series will be useful as a tutorial with practical.

Step by step I will be covering all the possible aspects of WCF. Same time I will be covering the SOA / Service based real life application scope especially for Connected and Distributed systems.

Please note that in the sample application every where I have used abu - which is my machine name, now for your case this will be your machine name

In Service Code
Uri
svcBaseAddress = new Uri(http://abu:8080/WCFKolkataNET/HOL); // Change "abu" by your machine name

In Client Code
EndpointAddress
endPointAddr = new EndpointAddress(http://abu:8080/WCFKolkataNET/HOL/MyService); // Change "abu" by your machine name

Posted by abu | with no comments
Filed under:

This series of Webcast includes A2Z[complete] ASP.NET AJAX Client Libraries - calling Web services, object-oriented development, creating controls, creating behaviors, and tips and tricks for development

WCF Services from ASP.NET AJAX

ASP.NET AJAX Client Library

Posted by abu | with no comments
Filed under: , ,

The series blog post on REST in WCF

  • REST in WCF - Part I (REST Overview)
  • REST in WCF - Part II (AJAX Friendly Services, Creating The Service)
  • REST in WCF - Part III (AJAX Friendly Services, Consuming The Service)
  • REST in WCF - Part IV (HI-REST - Exposing a service via GET - Configuring the service)
  • REST in WCF - Part V (HI-REST - Exposing a service via GET - The ServiceContract and Implementation)
  • REST in WCF - Part VI (HI-REST - Consuming our GET service via AJAX)
  • REST in WCF - Part VII (HI-REST - Implementing Insert and Update
  • REST in WCF - Part VIII (HI-REST - Implementing Delete)
  • REST in WCF - Part IX - Controlling the URI
  • REST in WCF - Part X - Supporting Caching and Conditional GET
  • Posted by abu | with no comments
    Filed under: , , ,

    One of my interesting thing is "URL Rewriting". The first time I have implemented it through implementing HTTPHandler using .NET 1.1. Same concept I have applied to a Document Management Service [DMS] project to PUT the document and GET the document by an .ASMX WebService. There I added verb * using wild charater in IIS 6.0 as well as added  <httpHandler> node in web.config. Then we got in different way in .NET 2.0. Finally this time we got using URITemplate, WebGet, WebInvoke in WCF 3.5 SP1.

    The UriTemplate class provides methods for working with sets of URIs that share a common structure for URL Rewriting.
    As this follows based on the URL pattern comprises left portion of URI which is fixed and rest is dynamic where certain parameter is getting manipulated or changed to request a page. System.UriTemplate provides runtime support for URI template syntax.
    UriTemplate is to manipulate parameters using ByName and ByPosition.
    [WebGet] - supports HTTP GET method
    WebOperationContext provides easy access to Web specifics (e.g., headers, status codes)
    [WebInvoke] supports other HTTP methods; POST is default method

    http://blogs.msdn.com/endpoint/archive/2008/08/22/rest-in-wcf-part-ix-controlling-the-uri.aspx

    http://weblogs.asp.net/jgalloway/archive/2007/05/02/mix07-wcf-adding-system-uritemplate-webget-and-webinvoke.aspx

    Corresponding to previous version's URL concept the available resources are in

    http://msdn.microsoft.com/en-us/library/ms972974.aspx

    http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx

    http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/

     

    Posted by abu | with no comments
    Filed under: , , , ,

    So nicely step by step blogged by Eric Lippert for "Covariance and Contravariance" as "Fabulous Adventures In Coding"

  • Covariance and Contravariance, Part Eleven: To infinity, but not beyond
  • Immutability in C# Part Three: A Covariant Immutable Stack
  • Covariance and Contravariance in C#, Part Ten: Dealing With Ambiguity
  • Covariance and Contravariance in C#, Part Nine: Breaking Changes
  • Covariance and Contravariance in C#, Part Eight: Syntax Options
  • Covariance and Contravariance in C# Part Seven: Why Do We Need A Syntax At All?
  • Covariance and Contravariance in C#, Part Six: Interface Variance
  • Covariance and Contravariance In C#, Part Five: Higher Order Functions Hurt My Brain
  • Covariance and Contravariance in C#, Part Four: Real Delegate Variance
  • Covariance and Contravariance in C#, Part Three: Method Group Conversion Variance
  • Covariance and Contravariance in C#, Part Two: Array Covariance
  • Covariance and Contravariance in C#, Part One
  • Posted by abu | with no comments
    Filed under: ,

    Very good resources for the coming version...

    Sam Ng

    Chris Burrows

    Eric Lippert

    PDC

    Posted by abu | with no comments
    Filed under: , , , ,

    "What's Next?" - Everybody is interested to know about new and upcoming things. While I purchase new thing, I could not wait to use. Previously I was curious to know abour Whidbey, Orcas, WinFx ( Indigo, Avalon)... Next???

    Now it is the case for Oslo too.

    Now after PDC 2008, may many of us come to know about Visual Studio 2010.

     "10" - this one very significant number for football player or hockey player; only the most important player are getting No. 10 as their jersey number.

    Yes, this time, it is "10" - Visual Studio 2010, VB.NET 10, Visual Studio 10 is the NEXT.

    Here are some very useful links related to this.

    http://blogs.msdn.com/kirillosenkov/archive/2008/11/20/links-about-visual-studio-2010-and-c-4-0.aspx

    http://weblogs.asp.net/pgielens/archive/2008/10/27/the-future-of-c-4-0.aspx

    http://code.msdn.microsoft.com/csharpfuture

    http://code.msdn.microsoft.com/csharpfuture/Wiki/View.aspx?title=Home&version=4

     http://blogs.msdn.com/bclteam/archive/2008/11/04/what-s-new-in-the-bcl-in-net-4-0-justin-van-patten.aspx

    Posted by abu | with no comments
    Filed under: , ,

    C# Language Enhancement

    C# 3,0 LINQ

    C# 3.0 and LINQ With Language Extention

    C# Dynamic Language Enhancement

    C# 4.0 can be found on the Downloads page. The CSharpDynamic samples include several projects showing how to use Dynamic with Office, IronPython and other technologies. There is also a covariance and contravariance example, and an example show how to use the new IDynamicObject interface to create native C# objects that can be called dynamically.

    The document New Features in C# 4.0 is a high level description of the additions to the C# language, and the samples are designed to show off the new language features, particularly around the dynamic scenario.

    Posted by abu | with no comments
    Filed under: ,

    Application Architecture Pocket Guides http://blogs.msdn.com/jmeier/archive/tags/AppArch/default.aspx

    Agile Architecture Method Pocket Guide
    Posted by abu | with no comments
    Filed under: ,

    In my free time I like to see videos from Channel9, TechEd and PDC sessions.

    Guide and Self Learning Resources are avilable @

    NetFxGuide

    http://www.netfxguide.com/guide/wcf.aspx

    http://www.netfxguide.com/guide/WPF.aspx

    http://www.netfxguide.com/guide/WF.aspx

    channel9

    http://channel9.msdn.com/tags/WCF/

     http://channel9.msdn.com/tags/WF/

    http://channel9.msdn.com/tags/WPF/

    Posted by abu | with no comments
    Filed under: , , ,

    A bird’s-eye view from 1000 feet in MSDN... Conceptual diagram whitch cover A2Z Basic Key Words associated with WCF.
    http://msdn.microsoft.com/en-us/library/ms733128.aspx

    WCF Architecture Digram

    The WCF Architecture 
    Basic level articles from MSDN

    http://msdn.microsoft.com/en-us/library/aa480210.aspx

    A Developer's Primer from Code Project
    http://www.devx.com/codemag/Article/31674/0/page/1

     

    Posted by abu | with no comments
    Filed under: ,

    http://www.microsoft.com/learning/mcp/mcts/vstudio/2008/default.mspx

    MCTS certifications

    MCTS: .NET Framework 3.5, Windows Presentation Foundation Applications

    MCTS: .NET Framework 3.5, Windows Communication Foundation Applications

    MCTS: .NET Framework 3.5, Windows Workflow Foundation Applications

    MCTS: .NET Framework 3.5, Windows Forms Applications

    MCTS: .NET Framework 3.5, ASP.NET Applications

    MCTS: .NET Framework 3.5, ADO.NET Applications

    Preparation Guide for Exam 70-503 - eLearining

    TS: Microsoft .NET Framework 3.5 – Windows Communication Foundation Application Development

    http://www.microsoft.com/learning/en/us/exams/70-503.mspx

    All the papers details...

    Applications that run on the Windows platform

    and

    Compelling user interfaces with Windows Presentation Foundation

    MCTS: .NET Framework 3.5, Windows Presentation Foundation Applications

    Exam 70-536: TS: Microsoft .NET Framework – Application Development Foundation

    and

    Exam 70-502: TS: Microsoft .NET Framework 3.5, Windows Presentation Foundation Application Development

    Distributed applications that communicate with services or other applications in a connected or disconnected state

    MCTS: .NET Framework 3.5, Windows Communication Foundation Applications

    Exam 70-536: TS: Microsoft .NET Framework – Application Development Foundation

    and

    Exam 70-503: TS: Microsoft .NET Framework 3.5 – Windows Communication Foundation Application Development

    Applications that host workflows for your organization

    MCTS: .NET Framework 3.5, Windows Workflow Foundation Applications

    Exam 70-536: TS: Microsoft .NET Framework – Application Development Foundation

    and

    Exam 70-504: TS: Microsoft .NET Framework 3.5 – Windows Workflow Foundation Application Development

    Windows-based applications that run on corporate servers or user desktop computers

    MCTS: .NET Framework 3.5, Windows Forms Applications

    Exam 70-536: TS: Microsoft .NET Framework – Application Development Foundation

    and

    Exam 70-505: TS: Microsoft .NET Framework 3.5, Windows Forms Application Development

    Data-driven applications that access data from various sources such as SQL Server, Oracle, Microsoft Office Access, object data sources, XML, or other flat-file sources

    MCTS: .NET Framework 3.5, ADO.NET Applications

    Exam 70-536: TS: Microsoft .NET Framework – Application Development Foundation

    and

    Exam 70-561: TS: Microsoft .NET Framework 3.5, ADO.NET Application Development

    Web-based applications that run on the ASP.NET platform and are hosted on Internet Information Server

    MCTS: .NET Framework 3.5, ASP.NET Applications

    Exam 70-536: TS: Microsoft .NET Framework – Application Development Foundation

    and

    Exam 70-562: TS: Microsoft .NET Framework 3.5, ASP.NET Application Development

    Posted by abu | with no comments

    If you are an ASP.NET, WCF advanced serious developer, would like to play with internals of ASP.NET, Web Service, WCH hosting with IIS 7.0; this this article will be very useful to know it's architecture.

    http://learn.iis.net/page.aspx/101/introduction-to-iis7-architecture/

     

    Posted by abu | with no comments
    Filed under: , ,

    Message-Oriented Web Services
    Author Dr. Jim Webber,Service-Oriented Systems Practice Lead, ThoughtWorks

    www.acs.org.au/nsw/sigs/ws/presentations/2006-11/Message-OrientedWebServices.ppt

    This PPT is very much informative and conceptual; specially for those who is trying to build the concept of SOA/Web Service/WCF, messaging service. Here fundamentals are covered.

    A Lap around Windows Communications Foundation
    http://download.microsoft.com/download/c/d/5/cd57f3cb-de13-46b0-a526-e1781eea5ecd/ALapAroundtheWCF.ppt


    Windows Communication Foundation (Indigo) Hello World Tutorial
    http://dotnet.org.za/hiltong/articles/52518.aspx

    Windows Communication Foundation Tutorial - Part 2 (DataContract vs Serializable)
    http://dotnet.org.za/hiltong/articles/50121.aspx

    Windows Communication Foundation Tutorial - Part 3 - Messaging & MessageContracts
    http://dotnet.org.za/hiltong/articles/53552.aspx

    Posted by abu | with no comments
    Filed under:

    In the last posted some links related to concept and fundamentals of WCF. It basics of WCF, Contracts[Service, Operational, Data, Message].

    A service can be hosted by Internet Information Services (IIS), Windows Process Activation Service (WAS), a Windows service, or by a managed application.

    For the hosting model to include Windows Services and Self-Hosting options this is one of the best articles from MSDN http://msdn.microsoft.com/en-us/library/bb332338.aspx

    What I feel that here in WCF as many as options are available for hosting. Based on the requirement and available platform the option need be choose. Therefore, it's always require to all the available optios and it's advantages and disadvantages to optimize the same.

    This articles covers all the poosible way (intermediate level) for Hosting WCF Services http://www.devx.com/codemag/Article/33655

    From MSDN...

    Hosting in Internet Information Services
    Hosting in Windows Process Activation Service
    Hosting in a Windows Service Application
    Hosting in a Managed Application

    Posted by abu | with no comments
    Filed under: ,

    To create robust distributed service with WCF it is very essential to understand WS-* specifications.

    List of Web service specifications - http://en.wikipedia.org/wiki/List_of_Web_service_specifications

    In .NET this supports as Web Services Enhancements (WSE). http://en.wikipedia.org/wiki/Web_Services_Enhancements

    The Web Service Specifications is to provide interoperable protocols for Security, Reliable Messaging, and Transactions http://msdn.microsoft.com/en-us/library/ms951274.aspx

    Windows Communication Foundation (WCF) implements a number of Web services protocols. http://msdn.microsoft.com/en-us/library/ms734776.aspx

    The article for WCF implementation of the WS-ReliableMessaging http://msdn.microsoft.com/en-us/library/aa480191.aspx is very nice.

    Posted by abu | with no comments
    Filed under: , ,

    Here is wellorganized list of all keynotes and sessions by code and title....

    http://blogs.msdn.com/mswanson/pages/PDC2008Sessions.aspx

    From this all the session can be downloaded, available presentation slides and sample code, if applicable.

     

    Posted by abu | with no comments
    More Posts Next page »