gpt4 book ai didi

wcf - WCF Rest 服务的 SSL 实现

转载 作者:太空宇宙 更新时间:2023-11-03 14:53:01 29 4
gpt4 key购买 nike

 <system.serviceModel>
<!--WCF Service-->
<services>
<service name="Service.RestServices">
<endpoint address=""
binding="basicHttpBinding"
bindingConfiguration="secureHttpBinding"
contract="Service.IRestServices"/>

<endpoint address="mex"
binding="mexHttpsBinding"
contract="Service.IRestServices" />
</service>
</services>
<!--WCF Binding-->
<bindings>
<basicHttpBinding>
<binding name="secureHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</basicHttpBinding>
</bindings>
<!--WCF Behaviors-->
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpsGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>

在我的 Web.config 文件中还有什么我想考虑的吗?下面是我的服务界面。

Service Interface(IRestServices)

[操作合约]
[WebInvoke(ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, Method = "POST", UriTemplate = "Login", BodyStyle = WebMessageBodyStyle.Wrapped)]

当我尝试使用 HTTPS 进行调用时,我得到的响应是 404(未找到),而使用 HTTP 时,我正在正确获取响应数据。

如何使用 HTTPS 调用我的 rest api 网络服务 (WCF)?

最佳答案

我们必须在 WebService.svc 文件中定义工厂以支持 WCF 休息服务中的 Https

<%@ ServiceHost Language="C#" Debug="true" Service="XcellenceIt.Plugin.Misc.NopRestApi.Service.RestServices" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>

关于wcf - WCF Rest 服务的 SSL 实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32395910/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com