Creating a custom ServiceHostFactory
1. Follow the instructions in this blog to create a custom service host.
2. Follow the instructions in this blog to Host the service in a website
3. Open the NewProdSrvHost.cs file and change the constructor as shown below:
public NewProdSrvHost(params Uri[] baseAddresses) : base(typeof(ProductService),baseAddresses) { }
7. Override CreateServiceHost method
Protected override Sytem.ServiceModel.ServiceHost CreateServiceHost(type
{
return new NewProdSrvHost(baseAddresses);
}
8. Go to Svc file and add Factory attribute
<%@ ServiceHost Service="ProductServiceLibrary.ProductService" Factory="ProductServiceLibrary.ProdSrvHostFactory" %>
9. Open the Svc file in a browser
10. Examine the wsdl definition to verify that all the endpoint shown.
11. Test the client
Links
Custom Service Host - https://msdn.microsoft.com/en-us/library/aa395224(v=vs.110).aspx
1. Follow the instructions in this blog to create a custom service host.
2. Follow the instructions in this blog to Host the service in a website
3. Open the NewProdSrvHost.cs file and change the constructor as shown below:
public NewProdSrvHost(params Uri[] baseAddresses) : base(typeof(ProductService),baseAddresses) { }
4. Move the NewProdSrvHost to the ProductServiceLibrary Project.
5. Right click productServiceLibrary project > select Add > Class > name: ProdSrvHostFactory.
6. Make the class public and derive it from ServiceHostFactory5. Right click productServiceLibrary project > select Add > Class > name: ProdSrvHostFactory.
7. Override CreateServiceHost method
Protected override Sytem.ServiceModel.ServiceHost CreateServiceHost(type
{
return new NewProdSrvHost(baseAddresses);
}
8. Go to Svc file and add Factory attribute
<%@ ServiceHost Service="ProductServiceLibrary.ProductService" Factory="ProductServiceLibrary.ProdSrvHostFactory" %>
9. Open the Svc file in a browser
10. Examine the wsdl definition to verify that all the endpoint shown.
11. Test the client
Links
Custom Service Host - https://msdn.microsoft.com/en-us/library/aa395224(v=vs.110).aspx
Comments
Post a Comment