使用 ssl (https) 的 POST 的 WCF 问题

发布于 2024-08-21 12:14:16 字数 2191 浏览 4 评论 0原文

我目前有一个 webHttp 绑定 WCF Restful 服务,它在 http 上工作得很好,由于我的 webconfig 设置,我可以制作大尺寸的 Post,现在我尝试通过 https (ssl) 使用它,现在我的工作正常,但是我的帖子不,当文件大小超过一定数量时它不起作用,我想知道为什么会这样,因为我的 webconfig 指定了更大的大小并且它通过 http 运行良好,这是我的相关 webconfig..任何建议

谢谢

<system.serviceModel>
<client>
  <endpoint binding="webHttpBinding" bindingConfiguration="webHttp"
    contract="PrimeStreamInfoServices.IService1" name="Client" />
</client>
<bindings>
  <webHttpBinding>
    <binding name="webHttp" maxBufferSize="15000000" maxBufferPoolSize="15000000"
      maxReceivedMessageSize="15000000">
      <readerQuotas maxDepth="15000000" maxStringContentLength="10000000" 
        maxArrayLength="15000000" maxBytesPerRead="15000000" maxNameTableCharCount="10000000" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="string" />
      </security>
    </binding>
  </webHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="PrimeStreamInfoServices.Service1Behavior"
    name="PrimeStreamInfoServices.Service1">
    <endpoint address="" binding="webHttpBinding"
      bindingConfiguration="webHttp" contract="PrimeStreamInfoServices.IService1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="PrimeStreamInfoServices.Service1Behavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
      <serviceCredentials>
        <!--
        <serviceCertificate storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" findValue="TempCa" />
          -->
      </serviceCredentials>

    </behavior>
  </serviceBehaviors>
</behaviors>
<diagnostics>

  <messageLogging logMalformedMessages="true"  logMessagesAtServiceLevel="true"
    logMessagesAtTransportLevel="true" />

</diagnostics>

I currently have a webHttp binding WCF restful service, it works great over http, I can make Post of large sizes due to my webconfig settings, now I am trying to use it over https (ssl), now my gets work fine, but my posts dont, it doesnt work when the file size is over a certain amount, i was wondering why this could be since my webconfig specifies a larger size and it works good over http, here is my relevant webconfig.. any suggestions

Thanks

<system.serviceModel>
<client>
  <endpoint binding="webHttpBinding" bindingConfiguration="webHttp"
    contract="PrimeStreamInfoServices.IService1" name="Client" />
</client>
<bindings>
  <webHttpBinding>
    <binding name="webHttp" maxBufferSize="15000000" maxBufferPoolSize="15000000"
      maxReceivedMessageSize="15000000">
      <readerQuotas maxDepth="15000000" maxStringContentLength="10000000" 
        maxArrayLength="15000000" maxBytesPerRead="15000000" maxNameTableCharCount="10000000" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="string" />
      </security>
    </binding>
  </webHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="PrimeStreamInfoServices.Service1Behavior"
    name="PrimeStreamInfoServices.Service1">
    <endpoint address="" binding="webHttpBinding"
      bindingConfiguration="webHttp" contract="PrimeStreamInfoServices.IService1" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="PrimeStreamInfoServices.Service1Behavior">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="false" />
      <serviceCredentials>
        <!--
        <serviceCertificate storeLocation="LocalMachine" storeName="My" x509FindType="FindBySubjectName" findValue="TempCa" />
          -->
      </serviceCredentials>

    </behavior>
  </serviceBehaviors>
</behaviors>
<diagnostics>

  <messageLogging logMalformedMessages="true"  logMessagesAtServiceLevel="true"
    logMessagesAtTransportLevel="true" />

</diagnostics>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乖乖哒 2024-08-28 12:14:16

如果您想通过 SSL 使用 webHttpBinding,那么您必须将绑定配置为使用传输安全性,例如:

<security mode="Transport"> 

链接 提供了一些示例配置的详细信息,以处理以下错误:

找不到与 http 方案匹配的基地址
具有绑定 WebHttpBinding 的端点。注册基地址方案
是[https]

来自博客的示例配置:

<system.serviceModel>
<behaviors>    
 <endpointBehaviors>
  <behavior name="TestServiceAspNetAjaxBehavior">
   <enableWebScript />
  </behavior>
 </endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
 <service name="TestService">
  <endpoint address="" behaviorConfiguration="TestServiceAspNetAjaxBehavior"
   binding="webHttpBinding" bindingConfiguration="webBinding" contract="TestService" />
 </service>
</services>
 <bindings>
   <webHttpBinding>
     <binding name="webBinding">
       <security mode="Transport">
       </security>
     </binding>
   </webHttpBinding>
 </bindings>
</system.serviceModel>

If you want to use webHttpBinding over SSL then you have configure your binding to use transport security like:

<security mode="Transport"> 

This link provides some details with sample config to deal with the following error:

Could not find a base address that matches scheme http for the
endpoint with binding WebHttpBinding. Registered base address schemes
are [https]

Sample config from the blog:

<system.serviceModel>
<behaviors>    
 <endpointBehaviors>
  <behavior name="TestServiceAspNetAjaxBehavior">
   <enableWebScript />
  </behavior>
 </endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
 <service name="TestService">
  <endpoint address="" behaviorConfiguration="TestServiceAspNetAjaxBehavior"
   binding="webHttpBinding" bindingConfiguration="webBinding" contract="TestService" />
 </service>
</services>
 <bindings>
   <webHttpBinding>
     <binding name="webBinding">
       <security mode="Transport">
       </security>
     </binding>
   </webHttpBinding>
 </bindings>
</system.serviceModel>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文