理想行为
我想在本地测试apiman,以便查看apiman快速启动/回波服务的响应(或者如果这不再适用于apiman的最新版本,那么任何回显响应都会非常好)。
我试过什么
我在Ubuntu 17.10上安装了Ubuntu 17.10,使用的是官方的阿皮曼遗址中的以下内容:
mkdir ~/apiman-1.3.1.Final
cd ~/apiman-1.3.1.Final
curl http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.zip -o wildfly-10.1.0.Final.zip
curl http://downloads.jboss.org/apiman/1.3.1.Final/apiman-distro-wildfly10-1.3.1.Final-overlay.zip -o apiman-distro-wildfly10-1.3.1.Final-overlay.zip
unzip wildfly-10.1.0.Final.zip
unzip -o apiman-distro-wildfly10-1.3.1.Final-overlay.zip -d wildfly-10.1.0.Final
cd wildfly-10.1.0.Final
./bin/standalone.sh -c standalone-apiman.xml使用apiman (localhost:8080/apimanui/api-manager),我创建了一个Organisation、一个没有API Security的Public API、一个任意定义为http://localhost:8080/apiman-echo的Endpoint和一个Client App。由于API被定义为Public,因此我的理解是,不需要在Client App中定义Contract。API的Managed Endpoint是在GUI中提供的,如:
https://localhost:8443/apiman-gateway/MyTestOrganisation/MyTestAPI/2.0实际行为
以下是卷曲的结果:
# using the 'managed endpoint' provided in the gui - https
curl -k https://localhost:8443/apiman-gateway/MyTestOrganisation/MyTestAPI/2.0
<html><head><title>Error</title></head><body>404 - Not Found</body></html>
# using the 'managed endpoint' provided in the gui - http
curl -k http://localhost:8443/apiman-gateway/MyTestOrganisation/MyTestAPI/2.0
curl: (52) Empty reply from server
#using the endpoint i defined
curl -k http://localhost:8080/apiman-echo
<html><head><title>Error</title></head><body>404 - Not Found</body></html>速成班文档(Apiman.io/最新/crash-Course.html)指出,以下是apiman文件夹的内容,但是在我的pc上的wildfly-10.1.0.Final文件夹中搜索wildfly-10.1.0.Final不会返回结果:
├── apiman
│ ├── data
│ │ ├── all-policyDefs.json
│ │ └── apiman-realm.json
│ ├── ddls
│ │ ├── apiman_mysql5.ddl
│ │ └── apiman_postgresql9.ddl
│ ├── quickstarts
│ │ ├── echo-service
│ │ ├── LICENSE
│ │ ├── pom.xml
│ │ └── README.md
│ └── sample-configs
│ ├── apiman-ds_mysql.xml
│ └── apiman-ds_postgresql.xml我觉得我遗漏了几个与“安装”echo-service并使其可供测试相关的步骤。
在Apiman.gitbooks.io/apiman-用户指南和Apiman.gitbooks.io/apiman-生产指南中搜索Apiman.gitbooks.io/apiman-用户指南和Apiman.gitbooks.io/apiman-生产指南不会产生结果,而/最新/developer-guide.html声明:
模拟后端API是一个简单的"echo“API,它用描述它收到的请求的JSON有效负载来响应所有请求。
但我不知道如何解释和利用这些信息。
发布于 2017-11-26 10:29:08
我想我已经想出了解决办法。
博客帖子在这里中有一个名为“获取、构建和部署示例API”的部分,其内容似乎与apiman的早期版本更相关,但通常是正确的。
我在下面记录我的过程和结果,以防它帮助其他人。
博客文章中的以下步骤导致编译错误:
# make a directory on desktop to clone files into
mkdir ~/Desktop/my_container_for_echo_quickstart
# change into directory
cd my_container_for_echo_quickstart
# git clone
git clone https://github.com/apiman/apiman-quickstarts.git
# change into directory
cd apiman-quickstarts/echo-service/
# install maven so i can run `mvn package`
sudo apt install maven
# run `mvn package`
mvn package在记录了大量下载信息之后,显示了以下错误:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:37 min
[INFO] Finished at: 2017-11-26T19:39:29+10:00
[INFO] Final Memory: 17M/242M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.2:compile (default-compile) on project apiman-quickstarts-echo-service: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException然后我查找了java版本,得到了以下内容:
java -version
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.17.10.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)所以我做了这个:
sudo apt-get update
sudo apt-get install openjdk-8-jdk
mvn package得到了BUILD SUCCESS。这篇博文继续说:
如果您仔细查看输出的末尾,您将看到.war文件的位置
它实际上输出了.jar文件的位置:
Building jar: /home/me/Desktop/my_container_for_echo_quickstart/apiman-quickstarts/echo-service/target/apiman-quickstarts-echo-service-1.3.1.Final-javadoc.jar但是在同一个目录中有一个.war文件:
apiman-quickstarts-echo-service-1.3.1.Final.war因此,我将其复制到/home/me/apiman-1.3.1.Final/wildfly-10.1.0.Final/standalone/deployments中,并在另一个终端中看到服务器输出发生了变化:
20:10:54,463 INFO [org.jboss.as.repository] (DeploymentScanner-threads - 1) WFLYDR0001: Content added at location /home/me/apiman-1.3.1.Final/wildfly-10.1.0.Final/standalone/data/content/c6/*****/content
20:10:54,482 INFO [org.jboss.as.server.deployment] (MSC service thread 1-6) WFLYSRV0027: Starting deployment of "apiman-quickstarts-echo-service-1.3.1.Final.war" (runtime-name: "apiman-quickstarts-echo-service-1.3.1.Final.war")
20:10:54,667 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 76) WFLYUT0021: Registered web context: /apiman-echo
20:10:54,772 INFO [org.jboss.as.server] (DeploymentScanner-threads - 1) WFLYSRV0010: Deployed "apiman-quickstarts-echo-service-1.3.1.Final.war" (runtime-name : "apiman-quickstarts-echo-service-1.3.1.Final.war")这是由此产生的卷曲结果:
curl -k http://localhost:8080/apiman-echo
{
"method" : "GET",
"resource" : "/apiman-echo",
"uri" : "/apiman-echo",
"headers" : {
"Accept" : "*/*",
"User-Agent" : "curl/7.55.1",
"Host" : "localhost:8080"
},
"bodyLength" : null,
"bodySha1" : null
}虽然这是令人鼓舞的,但我担心的是,由于我首先使用/apiman-echo端点在apiman中设置了API,所以它将与我通过maven进程创建的端点发生冲突,但我们将看到。
https://stackoverflow.com/questions/47494613
复制相似问题