I am new about the using of Google Endpoint. I have imported in Eclipse EE the Helloworld sample from Google Java sample project. I did all the setup and i beging the test. If I type localhost:8080
on my Chrome Browser, I see the front end, and it's ok. But if I type
我是关于使用Google Endpoint的新手。我在Eclipse EE中导入了来自Google Java示例项目的Helloworld示例。我完成了所有的设置,并且测试结果。如果我在Chrome浏览器中输入localhost:8080,我会看到前端,没关系。但如果我打字
http://localhost:8080//_ah/api/explorer
for test the REST API, Chrome (even Explorer) redirect the address to:
为了测试REST API,Chrome(甚至资源管理器)将地址重定向到:
http://apis-explorer.appspot.com/apis-explorer/?base=http://localhost:8080/_ah/api#p/
And from here, I can test my REST API without problem. I am not expert of all the configuration that i can do on the web.xml
file, pom.xml
file, etc, but I would like to test my backend REST API without to be connected on internet. Is it possible to test and deploy the backend REST API offline on my local server, I mean, without to connect to Google site? I am using Windows 8.1.
从这里开始,我可以毫无问题地测试我的REST API。我不是我在web.xml文件,pom.xml文件等上可以执行的所有配置的专家,但我想测试我的后端REST API而无需在Internet上连接。是否可以在我的本地服务器上离线测试和部署后端REST API,我的意思是,无需连接到Google网站?我使用的是Windows 8.1。
1 个解决方案
#1
0
It's impossible to call endpoint method without internet connection if it's OAuth2 protected. Every method with User
param is using auth token which must be validated with OAuth2 server.
如果OAuth2受到保护,则无法在没有互联网连接的情况下调用端点方法。 User param的每个方法都使用auth令牌,必须使用OAuth2服务器验证。
To call not protected endpoint method you can use curl
or wget
utilities on Linux. I'm sure you will find corresponding tools for Windows.
要调用不受保护的端点方法,可以在Linux上使用curl或wget实用程序。我相信你会找到适合Windows的相应工具。
When you call a method using API Explorer the displayed header field contains information about the request. This data will be useful to call the methods on your own. With curl it will not be as easy as using API Explorer but here are examples:
使用API Explorer调用方法时,显示的标题字段包含有关请求的信息。这些数据对于自己调用方法很有用。使用curl它不会像使用API Explorer那么容易,但这里有例子:
@ApiMethod(
name = "test",
path = "test",
httpMethod = HttpMethods.GET
)
public StringResult getTest(@Nullable @Named("param") String param) {
return new StringResult("not protected method: " + param);
}
Using API Explorer:
使用API Explorer:
Header
头
GET http://localhost:8080/_ah/api/app/v1/test
Response
响应
200 OK
{
"value": "not protected method: null"
}
Now using curl
on terminal
现在在终端上使用curl
curl -X GET http://localhost:8080/_ah/api/app/v1/test
Response
响应
{
"value" : "not protected method: null"
}
Using any browser to test non protected GET methods
使用任何浏览器测试非受保护的GET方法
http://localhost:8080/_ah/api/app/v1/test?param=testParam
Response displayed in the browser
响应显示在浏览器中
{
"value" : "not protected method: testParam"
}
#1
0
It's impossible to call endpoint method without internet connection if it's OAuth2 protected. Every method with User
param is using auth token which must be validated with OAuth2 server.
如果OAuth2受到保护,则无法在没有互联网连接的情况下调用端点方法。 User param的每个方法都使用auth令牌,必须使用OAuth2服务器验证。
To call not protected endpoint method you can use curl
or wget
utilities on Linux. I'm sure you will find corresponding tools for Windows.
要调用不受保护的端点方法,可以在Linux上使用curl或wget实用程序。我相信你会找到适合Windows的相应工具。
When you call a method using API Explorer the displayed header field contains information about the request. This data will be useful to call the methods on your own. With curl it will not be as easy as using API Explorer but here are examples:
使用API Explorer调用方法时,显示的标题字段包含有关请求的信息。这些数据对于自己调用方法很有用。使用curl它不会像使用API Explorer那么容易,但这里有例子:
@ApiMethod(
name = "test",
path = "test",
httpMethod = HttpMethods.GET
)
public StringResult getTest(@Nullable @Named("param") String param) {
return new StringResult("not protected method: " + param);
}
Using API Explorer:
使用API Explorer:
Header
头
GET http://localhost:8080/_ah/api/app/v1/test
Response
响应
200 OK
{
"value": "not protected method: null"
}
Now using curl
on terminal
现在在终端上使用curl
curl -X GET http://localhost:8080/_ah/api/app/v1/test
Response
响应
{
"value" : "not protected method: null"
}
Using any browser to test non protected GET methods
使用任何浏览器测试非受保护的GET方法
http://localhost:8080/_ah/api/app/v1/test?param=testParam
Response displayed in the browser
响应显示在浏览器中
{
"value" : "not protected method: testParam"
}