【问题标题】:Using Static WAN IP Address for WCF in IIS在 IIS 中为 WCF 使用静态 WAN IP 地址
【发布时间】:2016-06-08 06:30:09
【问题描述】:

我已经设置了一个托管在 IIS 中的 WCF 服务。托管它的服务器没有 DNS 名称(没有域),只有一个外部静态 WAN IP 地址。

当我尝试使用 MEX 连接到 iOS 或 Windows 客户端中的服务以生成代理时,它使用的域名无法解析并失败。

WSDL 文档包含无法解析的链接。 - 下载“https://blah.com.au/NimThaiService.svc?xsd=xsd3”时出错。 - 无法解析远程名称:'blah.com.au'

如何更改我的 Web 配置文件或配置 IIS,以便使用静态 IP 而不是使用域名。

我需要 MEX 为 https://123.123.123.123/NimThaiService.svc

我已尝试按照其他文章中的说明进行操作。例如,建议添加<useRequestHeadersForMetadataAddress />。但是当我这样做时,我会收到一条错误消息,指出找不到资源。

我的网络配置文件如下:

<?xml version="1.0"?>

<configuration>

    <system.web>
      <compilation debug="true" targetFramework="4.5" />
      <httpRuntime targetFramework="4.5" />
    </system.web>

    <system.serviceModel>
      <behaviors>
        <serviceBehaviors>
          <behavior>
            <serviceMetadata httpsGetEnabled="true"/>
            <serviceCredentials>
                <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="NimThaiService.Authenticator, NimThaiService" />
            </serviceCredentials>
          </behavior>
        </serviceBehaviors>        
      </behaviors>

      <services>
        <service name="NimThaiService.NimThaiService">
          <endpoint address="https://mystaticwanipaddress:443/NimThaiService.svc" binding="basicHttpBinding" contract="NimThaiService.INimThaiService" bindingConfiguration="secureHttpBinding">
            <identity>
              <dns value="localhost" />
            </identity>
          </endpoint>
          <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange">
            <identity>
              <dns value="mystaticwanipaddress" />
            </identity>
          </endpoint>
        </service>        
      </services>

      <bindings>
        <basicHttpBinding>
          <binding name="secureHttpBinding">
            <security mode="Transport">
          <transport clientCredentialType="Basic" />
          <message clientCredentialType="UserName"/>
            </security>
          </binding>
        </basicHttpBinding>
      </bindings>

    </system.serviceModel>  

</configuration>

【问题讨论】:

    标签: wcf iis dns


    【解决方案1】:

    经过更多研究,我设法通过向 serviceMetadata 节点添加一个属性来解决此问题。

    我需要添加“httpsGetUrl”属性如下:

    <serviceMetadata httpsGetEnabled="true" httpsGetUrl="http://mystaticwanipaddress/NimThaiService.svc/basic"  />
    

    【讨论】:

      猜你喜欢
      • 2020-04-26
      • 2012-03-23
      • 2018-11-04
      • 2010-09-15
      • 2020-09-28
      • 1970-01-01
      • 2021-10-15
      • 1970-01-01
      • 2016-08-27
      相关资源
      最近更新 更多