[英]Getting http 400 bad request only if I use a relative address on my endpoint
I'm getting a: 我得到:
http 400 bad request
HTTP 400错误请求
error only if I use a relative address on my endpoint. 仅当我在端点上使用相对地址时,才会出现错误。
If I remove "basic" from the address I can view the WSDL definition without any problem: 如果我从地址中删除“基本”,则可以毫无问题地查看WSDL定义:
http://localhost:8001/Test/
But as soon as I add "basic" and open up a browser and type in: 但是,一旦我添加“基本”并打开浏览器并输入:
http://localhost:8001/Test/basic
i get the error. 我得到错误。
Here's my config: 这是我的配置:
<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>
ServiceHost: ServiceHost:
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();
}
The address field you have with "basic" in it comes after the full service URL. 完整服务URL之后是带有“基本”的地址字段。 I don't see a separate service activation in here or the name of your .svc file, but it would be something like
http://localhost:8001/Test/YourService.svc/basic
. 我在这里没有看到单独的服务激活,也没有看到您的.svc文件的名称,但这类似于
http://localhost:8001/Test/YourService.svc/basic
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.