繁体   English   中英

在服务器端设置 WCF 服务端点 web 配置为 https

[英]Set WCF Service endpoints at server side web config for https

我陷入了非常奇怪的境地,不知道如何解决这个问题。

我有非常简单的 WCF 服务与 http 一起工作得很好,但现在我想把它移到 https。

问题是需要托管的服务器。 服务器 IIS 有一个别名为“server-test.local”(不是“localhost”)和 http。 可以使用此别名在本地访问它。 并将其映射到具有 https 的域名(例如https://rmt.XXXXXXX.com )。

当我将 WCF 部署到该服务器并检查 WSDL 文件时,它具有本地别名而不是公共域名的映射。

它显示http://server-test.local/WCFService/Service.svc (错误)

我想要像https://rmt.XXXXXXXX.com/WCFService/Service.svc这样的映射(正确)

服务 web.config

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <pages controlRenderingCompatibilityVersion="4.0"/>
  </system.web>
  <system.serviceModel>

    <bindings>
      <basicHttpBinding>
        <binding maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
        </binding>
      </basicHttpBinding>
    </bindings>
    
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="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>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
   </system.serviceModel>
<system.webServer>    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>

当我将服务引用添加到 app. 它添加了以下不正确的端点。

客户端 App.config(端点)

<endpoint address="http://server-test.local/WCFService/Service.svc"
        binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IProcessing"
        contract="WCFService.IService" name="BasicHttpBinding_IProcessing" />

我可以通过浏览器访问 url 和 WSDL 文件,但无法使用任何服务方法。 我收到错误“没有可以接受消息的端点。”

我想我在这里遗漏了一些明显的东西。 请建议我更改。

您可以尝试更改 web.config 文件中的一些简单步骤,详细信息可以参考此帖子
1.在服务的web.config文件中启用传输级安全:

<security mode="Transport">
  <transport clientCredentialType="None"/>
</security>

2.使用bindingConfiguration标签指定绑定名称,使用behaviorConfiguration标签配置行为,然后指定托管服务的地址。 代码如下:

<service name="***" behaviorConfiguration="***">
    <endpoint address= https://rmt.XXXXXXXX.com/WCFService/Service.svc 
      binding="basicHttpBinding"  
      bindingConfiguration="???" 
      contract="WCFService.IService"/>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
</service>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM