托管在 IIS 中的 WCF 服务并使用静态 IP 访问它

WCF Service hosting in IIS and accessing it using Static IP

我在 IIS 中托管 WCF 服务,它在单个系统上运行良好,但是当我尝试使用远程计算机访问它时(我的系统有静态 ip),它询问我用户名和密码, 当我使用计算机凭据提供它时,它不接受 图1所示,

<?xml version="1.0"?>

<bindings>
  <basicHttpBinding>
    <binding name="Service1Soap">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Ntlm" proxyCredentialType="None"
            realm=""/>
        <message clientCredentialType="UserName" algorithmSuite="Default"/>
      </security>
    </binding>
  </basicHttpBinding>
</bindings>
 <services>
   <service name="WCF_Static.WCF_Service" behaviorConfiguration="maxBehaviour">
    <endpoint address="staticip" binding="basicHttpBinding" contract="WCF_Static.IWCF_Service" />
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <host>
      <baseAddresses>
        <add baseAddress="http://localhost/8080"/>
      </baseAddresses>
    </host>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="maxBehaviour">
      <serviceMetadata httpGetEnabled="true"/>
    </behavior>
  </serviceBehaviors>
</behaviors>

我使用的是客户端代理

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
    <system.serviceModel>
        <bindings>
            <basicHttpBinding>
                <binding name="BasicHttpBinding_IWCF_Service" />
            </basicHttpBinding>
        </bindings>
        <client>
            <endpoint address="http://123.123.123.123/Alias/Service.svc/staticip"  
                binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IWCF_Service"
                contract="ServiceReference1.IWCF_Service" name="BasicHttpBinding_IWCF_Service" />
        </client>
    </system.serviceModel>
</configuration>

参考链接here 谢谢,

找到了! ! :)

将服务部署为 http://localhost/abc/Service1.svc?wsdl or (http://127.0.0.1/abc/Service1.svc?wsdl) in IIS, on client side add service reference as http://localhost/abc/Service1.svc?wsdl or http://127.0.0.1/abc/Service1.svc?wsdl ,

但在客户端的 appconfig 中

将本地主机或 127.0.0.1 更改为实际 WCF 服务所在的 IP 地址 运行。 在这样的端点

端点地址="http://123.123.123.123/max/Service.svc/static"