C# 只有在端点上使用相对地址时,才能获取http 400错误请求
我得到一个: http 400错误请求 仅当我在端点上使用相对地址时出错 如果我从地址中删除“basic”,我可以毫无问题地查看WSDL定义:C# 只有在端点上使用相对地址时,才能获取http 400错误请求,c#,wcf,C#,Wcf,我得到一个: http 400错误请求 仅当我在端点上使用相对地址时出错 如果我从地址中删除“basic”,我可以毫无问题地查看WSDL定义: http://localhost:8001/Test/ 但只要我添加“基本”并打开浏览器并键入: http://localhost:8001/Test/basic 我得到了错误 这是我的配置: <system.serviceModel> <services> <service name="HostCo
http://localhost:8001/Test/
但只要我添加“基本”并打开浏览器并键入:
http://localhost:8001/Test/basic
我得到了错误
这是我的配置:
<system.serviceModel>
<services>
<service name="HostConsole.ContactService"
behaviorConfiguration="ServiceBehavior" >
<host>
<baseAddresses>
<add baseAddress="http://localhost:8001/Test/"/>
</baseAddresses>
</host>
<endpoint address="basic"
binding="basicHttpBinding"
contract="HostConsole.IContactService">
</endpoint>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
带有“basic”的地址字段位于完整服务URL之后。我在这里没有看到单独的服务激活,也没有看到.svc文件的名称,但它类似于
http://localhost:8001/Test/YourService.svc/basic
谢谢你的回复,我不是IIS主机,所以我没有*.svc文件。
ServiceHost host = new ServiceHost(typeof(ContactService));
try {
host.Open();
foreach (ServiceEndpoint se in host.Description.Endpoints) {
Console.WriteLine(string.Format(
"Address: {0}",
se.Address.Uri.AbsoluteUri));
}
Console.WriteLine("Enter to close");
Console.ReadLine();
host.Close();
}
catch (Exception ex) {
host.Abort();
Console.WriteLine(ex.Message);
Console.ReadLine();
}