这是我的代码:
public class callService extends AsyncTask<Void, Void, ArrayList<String>> {
@Override
protected ArrayList<String> doInBackground(Void... params) {
// TODO Auto-generated method stub
try{
System.out.println("::::::Inside try::::::");
ODataConsumer c = ODataJerseyConsumer.create("http://some:450/HHMSService_Android.svc");
//GetEmployee?&Mode=1&UserName='DR-OPD'&PWD='DR-OPD'
System.out.println("C :: "+c);
List<OEntity> listEntities = c.getEntities("GetEmployee?&Mode=1&UserName='DR-OPD'&PWD='DR-OPD'").execute().toList();
System.out.println("listEntities::::"+listEntities);
System.out.println("Size"+ listEntities.size());
if (listEntities.size() > 0) {
for (OEntity entity : listEntities) {
categories.add(entity.getProperty("DoctorID").getValue().toString()
+ " - "
+ entity.getProperty("DoctorName").getValue()
.toString());
}
}
}catch(Exception e){
System.out.println("Excepiton::::"+e);
}
return categories;
}
@Override
protected void onPostExecute(ArrayList<String> result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
adapter = new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_list_item_1, result);
list.setAdapter(adapter);
}
}
我添加了odata4j-0.7.0-clientbundle来消费Odata。 我在线上获得了NullPointerexception -
List<OEntity> listEntities = c.getEntities("GetEmployee?&Mode=1&UserName='DR-OPD'&PWD='DR-OPD'").execute().toList();
Plz帮助我。我的服务是在浏览器中给出响应。提前谢谢。
答案 0 :(得分:0)
您需要将过滤参数放入不同的方法,如下所示。
List<OEntity> listEntities = c.getEntities("GetEmployee")
.filter("-----PASS HERE FILTERING PARAMETERS").execute().toList();