Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Migrated From http://intranet.wavelet.asia/projects/tech/wiki/How_to_use_RESTful_Web_Service

Navigate to source code: src/webservices/webservices/rest/
Under this rest there have Controller, Resources and Model. To create a new web service need to maintain existing structure.

...

Most of the webservices contains: getgetCount and create actions.

 

calling the get action:

get action takes 3 parameters

...

SyncLogBean slBean = new SyncLogBean(mContext);
slBean.updateObject(ItemBean.TABLENAME, wsr.getMsg());
} else {
}
} catch (Exception e) {
e.printStackTrace();
}
finally{
if(con != null)
con.disconnect();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}@

 

calling the getCount action:

...

Gson gsonWs = new Gson();
WSResponse wsr = gsonWs.fromJson(json, WSResponse.class);
count = wsr.getCount();
} catch (Exception e) {
e.printStackTrace();
}
finally{
if(con != null)
con.disconnect();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return count;
}@

 

calling the create action:

...

1. userName (String) : for authentication.
2. password (String) : for authentication.
3. object (json String): This is a json formatted string of ItemObject if need to create an Item in EMP.

 

Structure of WSResponse.java file:

...