• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

WCF service from Windows Forms Applications

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

 

Summary
Review Date
Reviewed Item
WCF service from Windows Forms Applications
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on WCF service from Windows Forms Applications"

Leave a Message

Your email address will not be published. Required fields are marked *

Site Disclaimer, Copyright © 2016 - All Rights Reserved.