I am trying to consume WCF service in Android. I have hosted the service as
http://localhost:8080/UserService.svc 
This is my serviceModel section in web.config web.config :
<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="SimpleBasic">
          <security mode="None"/>
        </binding>
        <binding name="BasicOverHttps">
          <security mode="Transport"/>
        </binding>
      </basicHttpBinding>
    </bindings>
        <services>
            <service behaviorConfiguration="AndroidService.Service1Behavior" name="AndroidService.Service1">
                <endpoint address="" binding="wsHttpBinding" contract="AndroidService.IService1">
                    <identity>
                        <dns value="localhost"/>
                    </identity>
                </endpoint>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
            <service behaviorConfiguration="AndroidService.UserServiceBehavior" name="AndroidService.UserService">
                <endpoint address="ws" binding="wsHttpBinding" contract="AndroidService.IUserService">
                    <identity>
                        <dns value="localhost"/>
                    </identity>
                </endpoint>
        <endpoint address="basic" binding="basicHttpBinding" bindingConfiguration="SimpleBasic" contract="AndroidService.IUserService"/>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
        <endpoint address="web" binding="webHttpBinding" contract="AndroidService.IUserService" />
      </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="AndroidService.Service1Behavior">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
                <behavior name="AndroidService.UserServiceBehavior">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
which I can browse. I also checked the output for one method GetUser of service in WebServiceStudio. It came out to be fine. I then created an Android client application wherein I am trying to consume it.
HttpClient httpClient = new DefaultHttpClient();
          try
          {
              String url = "http://localhost:8080/UserService.svc/GetUser?name=Nitish";
            HttpGet method = new HttpGet( new URI(url) );
            HttpResponse response = httpClient.execute(method);
            if ( response != null )
            {
              Log.i( "login", "received " + getResponse(response.getEntity()) );
            }
            else
            {
              Log.i( "login", "got a null response" );
            }
          } catch (IOException e) {
            Log.e( "error", e.getMessage() );
          } catch (URISyntaxException e) {
            Log.e( "error", e.getMessage() );
          }
          catch (Exception e) {
            // TODO: handle exception
              Log.e( "error", e.getMessage() );
        }  
I get exception as follows in HttpResponse response = httpClient.execute(method); 
Connection to http://localhost:8080 refused 
I am running the application on device and have added following premissions in mainefest:
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />  
I went through this solution and tried to host the service on my IP address but no success.
 
     
     
     
    