2016-02-27 81 views
4

我对Google应用引擎和端点非常陌生,并且一直在编写基本端点功能并部署到云中。我成功地部署了HelloWorld的端点和测试它在API探险:http://localhost:8080/_ah/api/explorer我的Google云端点API在api资源管理器上不可见

但现在当我创建了一个新的端点API,并遵循相同的步骤(即在AppEngine上-web.xml中使用新的App Engine应用程序的名称部署,以appengine:update运行),api浏览器仍然显示我的HelloWorld端点,而不是我的新API“yourfirstendpoint”。

我已经搜索并试图找到一个答案无济于事 - 即时对不起,如果这是一个非常基本和愚蠢的问题(我确信它),但我会真的很感激,如果有人可以指向我在我应该做的正确的方向。

我的API

package com.example.zinglife; 
 

 
    import com.google.api.server.spi.config.Api; 
 
    import com.google.api.server.spi.config.ApiMethod; 
 
    import com.google.api.server.spi.config.ApiMethod.HttpMethod; 
 
    import com.google.api.server.spi.response.NotFoundException; 
 
    import com.google.appengine.api.datastore.Key; 
 
    import com.google.appengine.api.datastore.KeyFactory; 
 

 

 
    /** 
 
    * 
 
    * Defines endpoint functions APIs. 
 
    */ 
 
    @Api(name = "yourfirstapi", version = "v1", 
 
    scopes = {Constants.EMAIL_SCOPE }, 
 
      clientIds = {Constants.API_EXPLORER_CLIENT_ID}, 
 
      description = "API for hello world endpoints.") 
 

 
    public class YourFirstAPI 
 
    { 
 

 
    
 
    @ApiMethod(name = "storeUserModel") 
 

 
     private User storeUserModel(User user) throws NotFoundException 
 
    { 
 
     \t 
 
      String email = user.getEmail(); 
 
      Key key = KeyFactory.createKey("User",email); 
 
    \t 
 
     \t User userEntity = null; 
 
     \t try 
 
     { 
 
     \t \t 
 
    \t if (userEntity==null) 
 
    \t \t { \t 
 
    \t \t userEntity = new User(); 
 
    \t  userEntity.setName(user.getName()); 
 
    \t  userEntity.setEmail(user.getEmail()); 
 
    \t  userEntity.setCountry(user.getCountry()); 
 
    \t  // 
 
    \t  
 
    \t \t } 
 
    \t 
 
    \t \t \t 
 

 
    \t \t return userEntity; 
 
    \t 
 
    \t 
 
     }//*endtry 
 
     \t finally 
 
     \t { 
 
     \t \t 
 
     \t } 
 
     \t 
 
     
 
     
 
     
 
     
 
    } 
 
     
 

 
    }

运行代码后,App Engine的管理员登录: enter image description here

请让我知道是否需要任何其他信息:)

+0

api浏览器有时会出现故障。一般来说,你应该看到你的端点api。如果你不这样做,这里有一些可能性:你可能没有正确生成和部署发现文档,你上传了一个新版本,但你没有切换到默认的版本,你的浏览器中有过时的数据,应该清除浏览器缓存中,您忘记了将新的api类添加到web.xml中的com.google.api.server.spi.SystemServiceServlet init-params。 – konqi

回答

0

确保您已将您的新服务添加为值fo之一r EndPointsServlet的'services'参数。

<servlet> 
    <!-- This is version 2.0 of the endpoints framework. --> 
    <servlet-name>EndpointsServlet</servlet-name> 
    <servlet-class>com.google.api.server.spi.EndpointsServlet</servlet-class> 
    <init-param> 
     <param-name>services</param-name> 

     <!-- Comma separated classes that provide endpoints --> 
     <param-value> 
      com.mycompany.myproduct.endpoint.SomeServiceV1, 
      com.mycompany.myproduct.endpoint.SomeServiceV2, 
      com.mycompany.myproduct.endpoint.SomeOtherServiceV1, 
      com.mycompany.myproduct.endpoint.SomeOtherServiceV2, 
      com.mycompany.myproduct.endpoint.SomeOtherServiceV3 
     </param-value> 
    </init-param> 
</servlet> 
相关问题