How I can call an endpoint with the URL address exactly the same as the base address?
string localhost = "http://localhost:1387";
ServiceHost restHost = new ServiceHost(typeof(WebService), new Uri(localhost));
restHost.AddServiceEndpoint(typeof(IWebService), new WebHttpBinding(), "").Behaviors.Add(new RestBehavior());
hosts.Add(restHost);
This is the Service and I want to call it with http://localhost:1387
[WebInvoke(Method = "GET", UriTemplate = "", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)]
public Stream GetBase()
{
//do action
}
In WCF, if you do not set UriTemplate, WCF will add the method name after the base address as the URI of the service call. This is the interface for my service:
This is the help document after the service is started,you can see that even if I don't set UriTemplate, WCF still uses the method name as UriTemplate.So the base address cannot be the same as the address of the calling service.