WCF service from Windows Forms Applications

Ratings:
(4)
Views: 1080
Banner-Img
Share this blog:

Example to consume the WCF service from windows forms applications

  Screenshot_66     11Add reference to cls empdetails SVC from example 4 with the reference name as SR1 11 write the following code. //Some tirnes namespace Sr1 is not finding at that time we can write code like this Sr1 emp details client objs = new SR1 Empdetails client (); SR1. Emp data objD = Sr1. Emp data (); Protected void btninsert _ click (----) { objD.pemp ID = convert. Toirct 32 (txt emp id> text ); objD. pEname = txtEname. Text; objD. P Designation = txtdesignation. Text; objd. P doj = convert. To date time (txt Doj. Text); objd. Psalary = convert. To double (txtsalary. Text); objd. Pdeptno = convert. To int32 (txtdeptno. Text); int I = objs = insertrec (objD); Message box. Show (I + “record(s) inserted”); } Protected void btnupdate – click (---) { objD. P emp ID = convert. TOInt 32 (txtempid>text); ObjD. Pename = text e Name. text; Objd. Pdesignation = txtdesignation. Text; Objd. Pdoj = convext. To datetime (txt dotj. Text); Objd. Psalary = convert. To double (txtsalary. Text); Objd. Pdeptno = convert. toInt32 (txtdeptno. Text); Int I = objs. Updaterec (objD); Messagebox. Show (I + “ records) updated”)  

Services

Create a WCF service to find the salary of the given employee Screenshot_68     Create a WCF service to find the square value, cube value, factorial value of the given number. Screenshot_69     Create a WCF service in above client in 2 ways, 1) with  out using data contract class 2) by using data contract class  

 Basic terminology used in WCF services:-

ABC’s in WCF:- A 11address: B 11 binding : C11 contract 11in ABC’s of WCF service, ‘A’ stands for “Address”,  ‘B’ stands for “Binding”,  ‘c’ stands for “Contract”  

 Address:-

Address represents the location of WCF service where messages are received. Address uniquely identifies the end point and tells to the client / consumer where service is located. Address is specified by using URI (uniform resource Identifier) By using this URI client will identify the service location and reach the address with the help of http & TCP The hierarchical part of the RUI contains a unique location who’s format is dependent on the transport mechanism. Ex:- http://localhost/example4/cls empdetails.svc  

Bindings

The Binding specifies how to communicate with end points i.e., which transport protocol is to be  tcp/http/some other. The binding can contain binding elements. That specify the details like security mechanisms. Used to secure messages/the message patterns used by endpoints etc. Binding is constructed by the set of components called “binding elements”    

Steps of bindings

WS http binding  

  1. Basic http binding
  2. WS dual http binding
  3. WS federation Http binding
  4. Net TCP binding
  5. Net named pipe binding
  6. Net Ms MQBinding
  7. Net peer tcp binding

 

You liked the article?

Like: 0

Vote for difficulty

Current difficulty (Avg): Medium

EasyMediumHardDifficultExpert
IMPROVE ARTICLEReport Issue

About Author

Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.

Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox