Example to consume the WCF service from windows forms applications
Add reference to cls empdetails SVC from example 4 with the reference name as SR1 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”)
Create a WCF service to find the salary of the given employee
Create a WCF service to find the square value, cube value, factorial value of the given number.
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 address: B binding : C contract in ABC’s of WCF service, ‘A’ stands for “Address”, ‘B’ stands for “Binding”, ‘c’ stands for “Contract”
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
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
- Basic http binding
- WS dual http binding
- WS federation Http binding
- Net TCP binding
- Net named pipe binding
- Net Ms MQBinding
- Net peer tcp binding