【问题标题】:Error in Consuming OData from Android using Odata4j?使用 Odata4j 从 Android 消费 OData 时出错?
【发布时间】:2015-03-10 06:49:11
【问题描述】:

这是我的代码:

 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();

请帮助我。我的服务正在浏览器中给出响应。提前谢谢。

【问题讨论】:

  • getEntities("-----")方法中不能传递过滤参数。

标签: android web-services odata


【解决方案1】:

您需要将过滤参数放入不同的方法中,如下所示。

List<OEntity> listEntities = c.getEntities("GetEmployee")
.filter("-----PASS HERE FILTERING PARAMETERS").execute().toList();

【讨论】:

    猜你喜欢
    • 2011-05-03
    • 2013-11-25
    • 2011-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-15
    • 2022-11-02
    相关资源
    最近更新 更多