I’m new to WCF. I have made a simple self hosted service and added app.config but when I type address in the browser it is not showing me the service page that we get when we create our service http://localhost:8067/WCFService it is not displaying the service as it shows when we run service.
But when I try to add base service in public static void main instead of app.config it works fine m not getting yy?? Can anyone please help me?
Following is the app.config file manually added:
<configuration>
<system.serviceModel>
<services>
<service name="SelfHostedWCFService.WCFService">
<endpoint
address="http://localhost:8067/WCFService"
binding="wsHttpBinding"
contract="SelfHostedWCFService.IWCFService">
</endpoint>
</service>
</services>
</system.serviceModel>
</configuration>
Following is the Program.cs:
static void Main(string[] args)
{
ServiceHost host = new ServiceHost(typeof(SelfHostedWCFService.WCFService));
host.Open();
Console.WriteLine("Server is Running...............");
Console.ReadLine();
}
Following is the interface file manually added:
namespace SelfHostedWCFService
{
[ServiceContract]
interface IWCFService
{
[OperationContract]
int Add(int a, int b);
[OperationContract]
int Sub(int a, int b);
[OperationContract]
int Mul(int a, int b);
}
}
Following is the service.cs file manually added:
namespace SelfHostedWCFService
{
class WCFService:IWCFService
{
public int Add(int a, int b) { return (a + b); }
public int Sub(int a, int b) { return (a - b); }
public int Mul(int a, int b) { return (a * b); }
}
}
Is something wrong with my app.config or some other concept??
Everything seems ok at first glance – are you sure the service isn’t running??
Without any metadata being published, you cannot test the service using the WCF Test Client, nor can you generate a client-side proxy for it….
So I would recommend adding service metadata publishing to your service, and doing so, I was able to test that code of yours and it works just flawlessly.
To add metadata, change your config to:
Even with this config, you won’t see any service page when navigation to the URL – but the service is up and running – just use the WCF Test Client and see for yourself!