Search code examples
performancewcfwcf-data-serviceswcf-bindingwcf-security

WCF Service hosting in IIS and accessing it using Static IP


I am hosting a WCF service in IIS , it works fine on single system, but when I am trying to access it using remote machine(my system has static ip), it ask me username and password, when I provide that using computer credentials , it doesn't accept it Picture 1 shows that figure,

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

On Client side proxy I am using

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

Refereed links here Thanks,


Solution

  • Found ! ! :)

    deploy service as 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 ,

    but in appconfig on client side

    change the localhost or 127.0.0.1 to your ip address where actual WCF service is running. in endpoint like this

    endpoint address="http://123.123.123.123/max/Service.svc/static"