我有两个 WCF Web API 合同。在此之前,我很高兴我可以使用 TestClient。但是在我实现第二个端点之后,我必须定义端点(并且不能使用默认端点),之后,我在浏览器中什么也看不到,或者这条消息说“这个 XML 文件似乎没有任何与它。” 当我尝试去端点地址时。当我尝试配置文件时也是如此(虽然我不知道如何设置“EnableTestClient = true”)。我真的很感激任何帮助。
var baseurl = new Uri("http://localhost:7000/api/v1.0");
var config = new HttpConfiguration() { EnableTestClient = true };
config.CreateInstance = (type, context, request) => container.Resolve(type);
var host = new HttpServiceHost(typeof(ServiceAPI), config, baseurl);
host.Description.Behaviors.Add(
new ServiceMetadataBehavior() { HttpGetEnabled = true, HttpGetUrl = baseurl });
// Add MEX endpoint
//host.AddServiceEndpoint(
// ServiceMetadataBehavior.MexContractName,
// MetadataExchangeBindings.CreateMexHttpBinding(),
// "mex"
//);
//host.AddServiceEndpoint(typeof(IStatAPI), new WebHttpBinding(), "/stat");
//host.AddServiceEndpoint(typeof(IAlarmAPI), new WebHttpBinding(), "/alarm");
host.Faulted += (s, e) => Debug.WriteLine(e);
host.Open();