originally WS http binding is the combination of basic http binding and web services as well as web services extension. This can be written as, WS http binding = Basic http Binding + WS - *
Basic http binding | WS http Binding |
Data is transferred in plain text form between client and service component | Data is transferred in encrypted form between client and service component |
Supports all versions of ASP.net | supports 3.0, 3.5 and 4.0 versions of ASP.Net |
Supports backward compatibility i.e., service can be consumed from the client applications created in 1.0.1.1& 2.0 versions. | Doesn’t support backward compatibility i.e., service can’t be consumed form the client applications created in 1.0, 1.1&2.0 versions. |
Basic http binding follows SOAP 1.1 version | WS http binding follows SOAP 1.2 version; |
Security is not good. | security is good. |
Create a new window service with the name Example 7 change service 1.cs file name to sample service.cs add reference to system. Service model name space write the following code using system. Service model; namespace example7 { [service contract] public interface IMath numbers { [operation contract] int square (int x); [operation contract] int cube (int x); [operation contract] int factorial (int x); } Public partial class sumpleservice – service base, Imc dhnumbers Servicehost objs = null; Protected override void onstart (--) { obj = new service host (type of (sample service)); if (objs ! = null) objs. Opern(); } protected override void onstop(--) { if (objs! = null) { objs.close(): objs=null; } } public int squar (int x) { return x * x; } public int cube (int x) { public int factorial (int x) { return x*x*x; } public int factorial (int x) { int R = 1, I; for (i=1; i<=x;i++) { R=R * i } return R; } } Add new app.config into the windows service write the following code <configuration> <system.service Model> <service> <Service name = “Example 7 . sample service” behavior configuration = “Metadata support”> <host> <base addresses> <add base address = “net.tcp:// localhost : 8001/Example 7”/> <add base address = “http:// localhost:8081/Example7”/> </base addresses> </hot> <end point address = “Tcpmex” binding = “meretcp binding” contract = “metadata Exchange”/> <endpoint address = “ ” binding = “ws http binding” contract = “Example7. Imath numbers”/> </service> </services> <behaviors> <services behaviors> <behavior name = “metadatasupport”> <Service metadata http get enabled = “False” http sget url = “”/> </behavior> </service behaviors> </behaviors> </system.service model></configuration> Go to sample service cs designclick with right mouse button click on add installer this will add service process Installer and service installer classes to the application select serviceprocess Installer go to properties window, set the following properties according to local system select service installer à go to properties window, set the following properties service name sample service display name sample service start type automatic build the application (this will generate an exe) Go to visual studio 2008 command prompt to install the windows service in control panel service Change the disk location TC Excample 7 exe location type the following command i-e., Install util.exe - ; example 7. Exe This will install the service with in the control panel services. Go to control panel services select the sample service click with right mouse button click on start service will be started. Now this service is ready and can be consumed from any client application
Name check example 7 Design the form go to solution explorer select the solution click with right mouse button click on add service reference type the following address net.tcp//localbost : 8001/ example 7/tcpmex change the service reference 1 to sr1 click on ok (This coil) create proxy component) write the following code for calculate button protected void btn calculate _click(---) { SRI. Sample service client obj 1 = new SR1. Sample service client(); int a = convert. TOInt32 (txtnum.text): lblsquare text = obj1. Square (a). tostraing(); lblcube. Text =obj1. Cube ()a . tostring(); Lblfactorial . text = obj1. Factorial (a). tostring(); } when we are hosting the service at IIS, the service need not be continuously running rather when ever any client sends request, IIS will execute the service and sends, the result back to the client Whenever WCF service is hosted at IIS, the execution of the service will be under the control of IIS Whenever service is hosted with in console applications we should be always running as long as any client is consuming that service when we host the WCF service using console applications, the service will run under the control of CLR with the help of OS. When we host the WCF service using windows services the service starts running whenever operating system is started. Any client can consume this service until this is stopped manually (or) system is shutdown When the service is hosted using windows service it will run under the control of operating system with the help of CLR
You liked the article?
Like : 0
Vote for difficulty
Current difficulty (Avg): Medium
1/15
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