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

时间:2016-01-29 12:39:17

标签: performance wcf wcf-data-services wcf-binding wcf-security

我在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>

                       enter image description here               

在客户端代理我正在使用

    <?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 谢谢,

1 个答案:

答案 0 :(得分:0)

找到了! ! :)

在IIS中将服务部署为 http://localhost/abc/Service1.svc?wsdl 或( http://127.0.0.1/abc/Service1.svc?wsdl ),在客户端添加服务引用为 http://localhost/abc/Service1.svc?wsdl http://127.0.0.1/abc/Service1.svc?wsdl

但在客户端的appconfig中

将localhost或127.0.0.1更改为运行实际WCF服务的IP地址。 在像这样的端点

端点地址=&#34; http://123.123.123.123/max/Service.svc/static"