EliasMP EliasMP - 1 year ago 125
Android Question

Can´t reach WCF´s proyect in local

After Following a few tuto I programmed this code, which is not working. When I call the activity which contains Retrofit called, app crashed (that happens when I add the code for creating Retrofit object)....
I´m trying to consume a WCF (URL= (method´s name=devolverPisosA())

-- Interface --
public interface RestApi {
Call<List<pisoAlquiler>> devolverPisosA();

-- Pojo Class --
public class pisoAlquiler {
private int codigo;
private String fotos;

-- Activity --
public class Alquiler extends AppCompatActivity implements Callback<List<pisoAlquiler>> {

public static final String BASE_URL = "";

protected void onCreate(Bundle savedInstanceState) {

Retrofit retrofit = new Retrofit.Builder()

// prepare call in Retrofit 2.0
RestApi restApi = retrofit.create(RestApi.class);

Call<List<pisoAlquiler>> call = restApi.devolverPisosA();
//asynchronous call

public void onResponse(Call<List<pisoAlquiler>> call, Response<List<pisoAlquiler>> response) {

responsePisosAlquiler = (ArrayList<pisoAlquiler>) response.body();

public void onFailure(Call<List<pisoAlquiler>> call, Throwable t) {
Toast.makeText(Alquiler.this, t.getLocalizedMessage(), Toast.LENGTH_SHORT).show();

So my main_activity is calling (and starting a new activity) a second activity (which launch retrofit), but I never got to reach it. Second activity returns to main_activity instantly without doing anything (retrofit stuff)...

Thanks Mates...

The problem (and I´m guessing) could be my definition of endpoints. When I´m setting retrofit with baseUrl and get... My WCF looks like and the method which I want to call is devolverPisosA, but I don´t know how to set retrofit for consuming it.

Just trying

baseUrl =

Answer Source


The problem was I´m in Debbug Mode and WCF (by Visual Studio) and Android Studio wasn´t configurated in the same network.

For configuring Visual Studio for working with Android Studio in a Local Network, following the next:

Web.Config must to be set for listening from differents places. Between services and Behavior tags:

<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>

Open applicationhost.config allocated in Project Folder --> Config: Change the next one:

<site name="Proyect" id="2">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="c:\ProjectFolder\Proyect />
                <binding protocol="http" bindingInformation="*:52896:localhost" />


<site name="Proyect" id="2">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="c:\ProjectFolder\Proyect" />
                <binding protocol="http" bindingInformation="*:52896:localhost" />
              <binding protocol="http" bindingInformation="*:52896:*" />

With this, We can listen internal request.

Open Windows Firewall for that port.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download