我有一个OperationContract方法,我试图查询并将数据插入数据库.我正在使用一种POST方法并在浏览器中从javascript调用服务.WCF服务位于同一个域中,因此我不必使用JSONP.我也在修改数据,因此它应该是POST请求而不是GET请求.但是我仍然得到"方法不允许错误".有谁遇到过这种情况?
我的服务正在调用
http://some_url.com/services/ProfileService.svc/json/CurrentUser
Run Code Online (Sandbox Code Playgroud)
奇怪的是,GET即使我指定了一个,当我去这个网址的时候似乎是通过请求调用的POST.但是,在页面加载时,它似乎正在尝试POST请求.
进入网址时浏览器响应:
Request URL:http://some_url.com/services/ProfileService.svc/json/CurrentUser
Request Method:GET
Status Code:405 Method Not Allowed
Request Headersview parsed
GET /services/ProfileService.svc/json/CurrentUser HTTP/1.1
Run Code Online (Sandbox Code Playgroud)
这是我试图打电话的方法:
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json)]
public HIPUser GetCurrentUser()
{
string[] domainUser;
string Auth_User = HttpContext.Current.User.Identity.Name.ToString().ToLower();
domainUser = Auth_User.Split('\\');
string user = domainUser[1];
Debug.WriteLine(user);
ProfileManager pm = new ProfileManager();
var results = pm.GetUserByUserName(user);
if (results.Length > 0)
{
return results.First();
}
else …Run Code Online (Sandbox Code Playgroud) 我有两个加载器,一个用于填充绑定返回的数据到2 TextViews,另一个用于填充a ListView.如何确保为每种情况加载正确的装载程序?我在第一个加载器(WR_VIEWcase)似乎没有创建或加载的地方出现错误,因此onLoadFinished()它返回"没有这样的列发现错误",因为它正在访问不调用该列的第二个加载器.
在我的onCreate方法中,我为列表视图设置了适配器:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.workouts_options);
String[] uiBindFrom = { ExerciseTable.COLUMN_NAME };
int[] uiBindTo = { R.id.text1 };
SimpleCursorAdapter adapter = new SimpleCursorAdapter(
getApplicationContext(),
R.layout.exercises_row,
null,
uiBindFrom,
uiBindTo,
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
final ListView lv = (ListView) findViewById(android.R.id.list);
lv.setAdapter(adapter);
lv.setEmptyView(findViewById(android.R.id.empty));
lv.setClickable(true);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) {
}
});
getSupportLoaderManager().initLoader(WR_VIEW, null, this);
getSupportLoaderManager().initLoader(EXERCISE_VIEW, null, this);
}
Run Code Online (Sandbox Code Playgroud)
创建我的2个不同的CursorLoaders:
public Loader<Cursor> …Run Code Online (Sandbox Code Playgroud)