【问题标题】:My Google cloud endpoint API is not visible on the api explorer我的谷歌云端点 API 在 api explorer 上不可见
【发布时间】:2016-06-10 16:15:08
【问题描述】:

我对谷歌应用引擎和端点非常陌生,并且一直在编写基本的端点功能并部署到云端。我成功部署了一个 HelloWorld 端点并通过 API 资源管理器对其进行了测试:http://localhost:8080/_ah/api/explorer

但是现在,当我创建了一个新的端点 API 并遵循相同的步骤(即在 appengine-web.xml 中使用新的 APP 引擎应用程序名称部署,运行为 appengine:update)时,api explorer 仍然显示我的 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
     {
         
          String email = user.getEmail();
           Key key = KeyFactory.createKey("User",email);
        
            User userEntity = null;
            try 
        {
                
        if (userEntity==null)
            {   
              userEntity = new User();
              userEntity.setName(user.getName());
              userEntity.setEmail(user.getEmail());
              userEntity.setCountry(user.getCountry());
            //
             
            }
        
                

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

    }

运行代码后的 App Engine 管理员日志:

如果需要任何其他信息,请告诉我:)

【问题讨论】:

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

标签: google-app-engine google-cloud-endpoints


【解决方案1】:

确保您已将新服务添加为 EndPointsServlet 的“服务”参数的值之一。

<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>

【讨论】:

    猜你喜欢
    • 2016-01-20
    • 1970-01-01
    • 1970-01-01
    • 2023-03-05
    • 1970-01-01
    • 1970-01-01
    • 2018-01-19
    • 1970-01-01
    • 2015-05-10
    相关资源
    最近更新 更多