在端点类的创建方法 - 谷歌应用程序引擎应用程序、引擎、方法

2023-09-07 02:09:56 作者:童话=谎话

我是新来的App Engine应用程序development.I想在我的实体端点类来创建自定义的方法。对于我使用 @ApiMethod 标注在端点class.The问题定义自定义的方法是,当我从我的Andr​​oid客户端调用此方法会抛出 IOException异常。我不知道什么是我的code中的问题。请指导我。谢谢你。

端点code:

  @Api(NAME =feedmasterendpoint,命名空间= @ApiNamespace(ownerDomain =sampleregistrationapp.com,OWNERNAME =sampleregistrationapp.com,packagepath的=))公共类FeedMasterEndpoint {    @燮pressWarnings(未登记)        @ApiMethod(NAME =getUserFeed,列举HTTPMethod = HttpMethod.GET)        公众的ArrayList<串GT; getUserFeed(@Named(userId_fk)字符串ID){            EntityManager的经理= NULL;            ArrayList的<串GT; feedList =新的ArrayList<串GT;();            尝试{                经理= getEntityManager();                查询查询=经理                        .createQuery(从FeedMaster选择f.feedUrl f其中f.userId_fk =:用户id);                query.setParameter(用户id,身份证);                feedList =(ArrayList的<串GT;)query.getResultList();            } {最后                mgr.close();            }            返回feedList;        }} 

Android客户端code:

  StringCollection urlList =新StringCollection();Feedmasterendpoint.Builder建设者=新Feedmasterendpoint.Builder(                        AndroidHttp.newCompatibleTransport(),                        新JacksonFactory(),新的Htt prequestInitializer(){                            公共无效初始化(HTT prequest为arg0)                                    抛出IOException                            }                        });                Feedmasterendpoint终点= CloudEndpointUtils.updateBuilder(                        建设者).build();                。urlList = endpoint.getUserFeed(PARAMS [0])执行(); //它抛出IOException异常 

解决方案

很多搜索后我才知道,可能是没有这样的设备,从数据存储读取应用程序引擎的特定列,并解决这个问题我拿来整实体,它为我工作。

金元浦 互联网 时代 文化科技创新 创意新特征

I am new to App Engine application development.I want to create custom method in my entity endpoint class. For that i am using @ApiMethod annotation to define custom method in endpoint class.The problem is that when i invoke this method from my android client it throws IOException. I don't know what is the problem with my code. Please guide me. Thank you.

Endpoint code :

@Api(name = "feedmasterendpoint", namespace = @ApiNamespace(ownerDomain = "sampleregistrationapp.com", ownerName = "sampleregistrationapp.com", packagePath = ""))
public class FeedMasterEndpoint {

    @SuppressWarnings("unchecked")
        @ApiMethod(name = "getUserFeed", httpMethod = HttpMethod.GET)
        public ArrayList<String> getUserFeed(@Named("userId_fk") String id) {
            EntityManager mgr = null;
            ArrayList<String> feedList = new ArrayList<String>();
            try {
                mgr = getEntityManager();
                Query query = mgr
                        .createQuery("select f.feedUrl from FeedMaster f where f.userId_fk= :userId");
                query.setParameter("userId", id);
                feedList = (ArrayList<String>) query.getResultList();
            } finally {
                mgr.close();
            }
            return feedList;
        }
}

Android client code:

StringCollection urlList = new StringCollection();
Feedmasterendpoint.Builder builder = new Feedmasterendpoint.Builder(
                        AndroidHttp.newCompatibleTransport(),
                        new JacksonFactory(), new HttpRequestInitializer() {
                            public void initialize(HttpRequest arg0)
                                    throws IOException {

                            }
                        });

                Feedmasterendpoint endpoint = CloudEndpointUtils.updateBuilder(
                        builder).build();

                urlList = endpoint.getUserFeed(params[0]).execute(); //It throws IOException

解决方案

After lot of searching i got to know that might be there is no such facility to fetch particular column from Datastore of app engine and to solve that problem i fetched entire entity and it worked for me.