【发布时间】:2023-03-23 08:22:01
【问题描述】:
我正在尝试为 https 绑定创建 WCF 服务。该服务之前使用http。我更改了绑定(使用证书),现在我配置了 web.config - 但我总是收到错误代码“400 - 错误请求”。
使用以下方式调用 Web 服务: https://servername:444/FolderService.svc/FolderExists/1234 https://servername:444/FolderService.svc/Test
这是我的服务接口:
[ServiceContract]
public interface IFolderService
{
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/FolderExists/{accountnumber}")]
bool FolderExists(string accountnumber);
[OperationContract]
[WebGet(RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/Test")]
string Test();
}
这是我的 web.config:
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service name="myService.FolderService">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="myService.IFolderService"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpsGetEnabled="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
我尝试了很多不同的配置,但都没有成功。有没有人有想法(或工作示例)?
提前致谢!
【问题讨论】: