为什么我的WSDL仍然显示基本的HTTP绑定,并且位置值为HTTP?

7
我启用了https绑定,但我的WSDL的SOAP地址是http。有任何想法吗?谢谢!
<wsdl:service name="XXXX"><wsdl:port name="BasicHttpBinding_XXXXService" binding="i0:BasicHttpBinding_XXXService">
    <soap:address location="http://dev-soa-app/XXXX/XXXX/XXXService.svc"/></wsdl:port>
</wsdl:service>

这是我的web.config文件:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <customErrors mode="Off"/>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <configProtectedData>
    <providers>
      <add name="ConnStrings" type="System.Configuration.RsaProtectedConfigurationProvider, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" keyContainerName="ConnStrings" cspProviderName="" useMachineContainer="true" useOAEP="false"/>
    </providers>
  </configProtectedData>
  <connectionStrings configSource="ConnStrings\ConnStrings.config"/>
  <system.serviceModel>
    <services>
      <service name="XXXXService">
        <!-- Use a bindingNamespace to eliminate tempuri.org -->
        <endpoint address=""  name="XXXXService"
                  binding ="wsHttpBinding" bindingConfiguration="TransportSecurity"
                  bindingNamespace="WF.CT2.WebServices.XXXXService"
                  contract="WF.CT2.WebServices.XXXXService.SAMLService" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
      </service>
    </services>
    <bindings>
      <wsHttpBinding>
        <binding name="TransportSecurity">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <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" httpGetEnabled ="false" />
          <!-- 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>
2个回答

10

首先,您应该意识到 WSDL 中 service 元素中的 URL 仅仅是一个提示。您的客户端不应该依赖这个地址是服务的正确地址。

其次,需要了解如果您的服务是托管在 IIS 中,那么就是 IIS 决定将哪个地址放置在该元素中,基于您在 IIS 中的绑定。我怀疑您启用了站点主机上的 HTTP 和 HTTPS。通常可以通过在 IIS 管理器中 SSL 页面设置 "要求 SSL" 属性来将其切换为只使用 HTTPS。


谢谢John!这正是我在寻找的答案。 - WinFXGuy
正确!IIS配置会影响您的应用程序wsdl结果的结构。太棒了!对于我来说,在IIS上删除HTTP绑定是解决的。 - Riccardo Bassilichi

0
从您的Web.Config中删除httpGetEnabled ="false",并保持httpsGetEnabled="true"不变(如下所示)。
 <serviceBehaviors>
   <behavior>
     <serviceMetadata httpsGetEnabled="true" />
     <serviceDebug includeExceptionDetailInFaults="false"/>
 </behavior>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接