gpt4 book ai didi

wcf - 如何配置 WCF REST 以使用 SSL?

转载 作者:太空宇宙 更新时间:2023-11-03 13:04:24 28 4
gpt4 key购买 nike

我有一个很好的 WCF REST-ful JSON 服务,运行良好。当我尝试将其用于 HTTPS 时,问题就出现了。 Web.config 如下:

 <system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="StreamedRequestWebBinding" bypassProxyOnLocal="true" useDefaultWebProxy="false" hostNameComparisonMode="WeakWildcard" sendTimeout="10:15:00" openTimeout="10:15:00" receiveTimeout="10:15:00" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" transferMode="StreamedRequest">
<security mode="Transport">
<transport clientCredentialType = "None" />
</security>
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="WcfRESTFullJSON.Service1" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" bindingConfiguration="StreamedRequestWebBinding" contract="WcfRESTFullJSON.IService1" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<!--Him-->
<webHttp automaticFormatSelectionEnabled="true" />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
</system.serviceModel>

我在 IIS 上配置了自制证书。在我的客户端上:

WebClient WC;
...
WC.UploadData(URL, "POST", asciiBytes);

我们得到的:

The remote server returned an error: (500) Internal Server Error.

可能是什么问题?

最佳答案

问题已解决。在下一行中缺少对端点行为的引用...端点 behaviorConfiguration="web" address=""binding="webHttpBinding"bindingConfiguration="StreamedRequestWebBinding"contract="WcfRESTFullJSON.IService1"...在下面的 Web.config 中。谢谢 friend 们的帮助!终于在文章中找到了解决方案 Implementing 5 important principles of REST using WCF Services

    <services>
<service name="WcfRESTFullJSON.Service1" behaviorConfiguration="ServiceBehaviour">
<endpoint behaviorConfiguration="web" address="" binding="webHttpBinding" bindingConfiguration="StreamedRequestWebBinding" contract="WcfRESTFullJSON.IService1" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="web">
<!--Him-->
<webHttp automaticFormatSelectionEnabled="true" />
</behavior>
</endpointBehaviors>

关于wcf - 如何配置 WCF REST 以使用 SSL?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13829582/

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