【问题标题】:how to know port number of emulator android?如何知道模拟器android的端口号?
【发布时间】:2013-02-19 15:54:47
【问题描述】:

我有宁静的网络服务。一个应用 android 客户端通过 ajax 调用 restful web 服务。我不知道模拟器android的IP地址和端口,所以注册一个客户端地址访问restful web服务。请帮帮我。

android 应用中的代码 ajax

function Get() {
        $.ajax({
            url: "http://<web service domain>:31132/api/Customer",
            type: "GET",
            dataType: "json",
            contentType: "application/json;charset=utf-8",
            success: function (data) {

                $('#d').append("success");
            },
            error:function(){
                $('#d').append("Errorrr");
            }
        });
    }

在restful web service中代码注册客户端地址

public static void RegisterCors(HttpConfiguration httpConfig) {

        WebApiCorsConfiguration corsConfig = new WebApiCorsConfiguration();

        corsConfig.RegisterGlobal(httpConfig);


        corsConfig

          .ForResources("Customer")

          .ForOrigins("?????")// we need to register a client address access to webservice.This is my problem.

          .AllowAll();

    }

【问题讨论】:

    标签: android ajax restful-url


    【解决方案1】:
    adb shell ifconfig tiwlan0
    

    tiwlan0 是设备上 wi-fi 网络接口的名称

    【讨论】:

      猜你喜欢
      • 2015-12-28
      • 1970-01-01
      • 2020-09-20
      • 2018-11-07
      • 2013-02-04
      • 2017-07-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多