Archive for the ‘WCF’ Category

Connecting to a WCF Service Using Business Connectivity Services in Office 2010

FAST Failed to communicate with WCF Service

WCF Service open in Browser

use .svc/MEX


Categories: WCF Tags:

SharePoint web part using WCF

October 30, 2012 2 comments

using System;
using System.ComponentModel;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using System.Text;

namespace AddSalesRecordWebPart.SalesRecordWebPart
public class SalesRecordWebPart : WebPart

DataGrid datagrdSalesView = new DataGrid();
TextBox txtbxCompanyID = new TextBox();
TextBox txtbxCompanyName = new TextBox();
TextBox txtbxFY08Sales = new TextBox();
TextBox txtbxFY09Sales = new TextBox();
TextBox txtbxFY10Sales = new TextBox();
Button btnLoad = new Button();
Button btnGet = new Button();

protected override void Render(HtmlTextWriter writer)
txtbxCompanyID.Enabled = true;
txtbxCompanyName.Enabled = true;
txtbxFY08Sales.Enabled = true;
txtbxFY09Sales.Enabled = true;
txtbxFY10Sales.Enabled = true;
btnLoad.Text = “Add”;
btnGet.Text = “Get”;

writer.Write(“<td><b>Sales Information</b></td><td></td></tr>”);
writer.Write(“<tr><td>Sales Data:</td><td>”);
writer.Write(“</td></tr><tr><td>Company ID:</td><td>”);
writer.Write(“</td></tr><tr><td>Company Name:</td><td>”);
writer.Write(“</td></tr><tr><td>FY 08 Sales:</td><td>”);
writer.Write(“</td></tr><tr><td>FY 09 Sales:</td><td>”);
writer.Write(“</td></tr><tr><td>FY 10 Sales:</td><td>”);

btnLoad.Click += new EventHandler(btnLoad_Click);
btnGet.Click += new EventHandler(btnGet_Click);

void btnGet_Click(object sender, EventArgs e)
SalesWCFService.Service1Client proxy =
new SalesWCFService.Service1Client();
var salesData = proxy.getAllSalesData();

List<SalesObject> mySalesInfoList = new List<SalesObject>();

foreach (var item in salesData)
SalesObject tempEntity = new SalesObject();
tempEntity.companyID = item.companyID;
tempEntity.companyName = item.companyName.ToString();
tempEntity.fy08Sales = item.fy08Sales;
tempEntity.fy09Sales = item.fy09Sales;
tempEntity.fy10Sales = item.fy10Sales;

datagrdSalesView.DataSource = mySalesInfoList;

void btnLoad_Click(object sender, EventArgs e)
int companyID = Int32.Parse(txtbxCompanyID.Text);
string companyName = txtbxCompanyName.Text;
int fy08Sales = Int32.Parse(txtbxFY08Sales.Text);
int fy09Sales = Int32.Parse(txtbxFY09Sales.Text);
int fy10Sales = Int32.Parse(txtbxFY10Sales.Text);

SalesWCFService.Service1Client proxy =
new SalesWCFService.Service1Client();
proxy.addSalesRecord(companyID, companyName, fy08Sales,
fy09Sales, fy10Sales);

WCF training videos

Categories: Training, WCF Tags:


The architecture
WCF is designed in accordance with service oriented architecture principles to support distributed computing where services are consumed by consumers. Clients can consume multiple services and services can be consumed by multiple clients. Services are loosely coupled to each other. Services typically have a WSDL interface which any WCF client can use to consume the service, irrespective of which platform the service is hosted on. WCF implements many advanced web services (WS) standards such as WS-Addressing, WS-ReliableMessaging and WS-Security.
A WCF service is composed of three parts — a Service class that implements the service to be provided, a host environment to host the service, and one or more endpoints to which clients will connect. All communications with the WCF service happens via the endpoints. The endpoints specify a Contract that defines which methods of the Service class will be accessible via the endpoint; each endpoint may expose a different set of methods. The endpoints also define a binding that specifies how a client will communicate with the service and the address where the endpoint is hosted.
In Windows Vista, Windows Server 2008 and Windows 7 (operating systems that include IIS 7), Windows Activation Services can be used to host the WCF service. Otherwise the WCF service can be hosted in IIS, or it can be self-hosted in any process by using the ServiceHost class, which is provided by WCF. A self-hosted WCF service might be provided by a console-based application, a Windows Forms application, or a Windows service (the Windows counterpart to a daemon), for example.
A WCF client connects to a WCF service via an endpoint. Each service exposes its contract via one or more endpoints. An endpoint has an address, which is a URL specifying where the endpoint can be accessed and binding properties that specify how the data will be transferred.
The mnemonic “ABC” can be used to remember Address / Binding / Contract. Binding specifies what communication protocols are used to access the service, whether security mechanisms are to be used, and the like. WCF includes predefined bindings for most common communication protocols such as SOAP over HTTP, SOAP over TCP, and SOAP over Message Queues, etc. Interaction between WCF endpoint and client is done using SOAP envelope. SOAP envelope are in simple XML form that make WCF platform independent.
When a client wants to access the service via an endpoint, it not only needs to know the contract, but it also has to adhere to the binding specified by the endpoint. Thus, both client and server must have compatible endpoints.
With the release of the .NET Framework 3.5 in November 2007, Microsoft released an encoder that added support for the JSON serialization format to WCF.[1] This allows WCF service endpoints to service requests from AJAX-powered web pages.

Windows Communication Foundation is a programming platform and runtime system for building, configuring and deploying network-distributed services. It is the latest service oriented technology; Interoperability is the fundamental characteristics of WCF. It is unified programming model provided in .Net Framework 3.0. WCF is a combined feature of Web Service, Remoting, MSMQ and COM+. WCF provides a common platform for all .NET communication.
Interoperability -The ability to exchange and use information (usually in a large heterogeneous network made up of several local area networks)

1. WCF is interoperable with other services when compared to .Net Remoting, where the client and service have to be .Net.
2. WCF services provide better reliability and security in compared to ASMX web services.
3. In WCF, there is no need to make much change in code for implementing the security model and changing the binding. Small changes in the configuration will make your requirements.
4. WCF has integrated logging mechanism, changing the configuration file settings will provide this functionality. In other technology developer has to write the code.
Making right design for your requirement is little bit difficult. I will try to help you on solving these difficulties in the following article.

Categories: Microsoft, WCF