【发布时间】: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