I created a service without specifying a base address in the servicehost constructor. and added the endpoint to the host by calling the AddServiceEndpoint method. In the AddServiceEndpoint method, I provide the full address of the service. On the client proxy, the call is interrupted with the exception: "There was no listening to the endpoint at http: // localhost: 8000 / Test / TestService , which could receive this message. Caused by the wrong address or SOAP action. For more information, see InnerException, if available. " below is an example of ServiceHost code and client proxy
using (ServiceHost host = new ServiceHost(typeof(Test.TestService)))
{
host.AddServiceEndpoint(typeof(Test.ITestService),
new BasicHttpBinding(), "http://localhost:8000/Test/TestService");
Console.ReadLine();
host.Close();
}
Client proxy:
EndpointAddress ep = new EndpointAddress("http://localhost:8000/Test/TestService");
ITestService proxy = ChannelFactory<ITestService>.CreateChannel(new BasicHttpBinding(), ep);
string s = proxy.HelloWorld();
The line in which I call proxy.Helloworld does not work, and an exception is thrown.
Servicehost , .
, servicehost.
using (ServiceHost host = new ServiceHost(typeof(Test.TestService),new Uri("http://localhost:8000/Test")))
{
host.AddServiceEndpoint(typeof(Test.ITestService),
new BasicHttpBinding(), "/TestService");
Console.ReadLine();
host.Close();
}
- , ?
:
:
[ServiceContract]public interface ITestService
{
[OperationContract]
string HelloWorld();
}
public class TestService: ITestService
{
public string HelloWorld()
{
return "Hello World";
}
}
, - servicehost , servicehost uri AddServicepoint .