For making WCF service to work you need to add the services end point and you can also define the binding with different transporter for e.g net.tcp, http
Below is the code how you can define these bindings.
1.First you need to define the ServiceHost which will take type of your class which inherited the service contract.
using System.ServiceModel;
ServiceHost selfHost = new ServiceHost(typeof("Type of your class"), baseAddress);
2. Second you need to Add service point to this service host which will take type of you service contract and also the name of class which inherited this service contract.
selfHost.AddServiceEndpoint(
typeof(IUploadInterface),
new WSHttpBinding(),
"UploadClass");
3. You need to create the service meta behaviour and need to set HttpGetEnable to true so that it will enabled Http request on your service and you also need to define the url of your service which include the port number and the class name.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
smb.HttpGetUrl = new Uri("http://localhost:8000/UploadClass");
selfHost.Description.Behaviors.Add(smb);
4. You need to open the service host
selfHost.Open();
1 comment:
Good dispatch and this post helped me alot in my college assignement. Say thank you you seeking your information.
Post a Comment