2017-11-26 4 views
0

望ましい行動APIをapimanでローカルにテストするには?

私はapiman-quickstarts/echo-serviceの応答を表示するために、ローカルapimanのAPIをテストしたい(つまりapimanの最新バージョンではもはや適用された場合や、任意のエコー応答は素晴らしいことないだろう)。私はthe official apiman siteから、以下のものを使用してUbuntu 17.10apimanをインストール

を試してみた何

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のGUI(localhost:8080/apimanui/api-manager)を使用して、私は、とPublic APIOrganisationを作成no API SecurityEndpointを任意にhttp://localhost:8080/apiman-echoと定義し、Client Appとする。 APIはPublicと定義されているため、をClient Appに定義する必要はありません。 としてGUIで提供されたAPIのManaged Endpoint

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/latest/crash-course.htmlが)と述べています以下はapimanフォルダの内容ですが、私のPCのwildfly-10.1.0.Finalフォルダのquickstartsを検索すると結果は返されません:

├── 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-user-guideechoの検索とapiman.gitbooks.io/apiman-production-guideapiman.io/latest/developer-guide.html状態ながら、何の結果を生成しません:

the mock back-end API is a simple "echo" API that responds to all requests with a JSON payload describing the request it received

をしかし、私は解釈し、その情報を利用する方法がわからないです。

答えて

0

私は解決策を見つけたと思います。

blog post hereには、「apiの以前のバージョンとの関連性が高いと思われる内容の例APIの取得とビルドとデプロイ」というセクションがありますが、一般に当てはまります。

他の誰かを支援するために、私のプロセスと結果を以下に記録します。

ブログ記事から、次の手順は、コンパイルエラーが発生しました:

[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を探しました:ダウンロード多くの情報をログインした後

# 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 

、次のエラーが表示されましたバージョンを取得し、次を取得しました:

私はこれを行いました:

sudo apt-get update 
sudo apt-get install openjdk-8-jdk 
mvn package 

そして、BUILD SUCCESSを得ました。ブログの記事は継続する:

If you look closely, near the end of the output, you’ll see the location of the .war file

それ.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にコピーし、もう一方の端末でサーバの出力が変化するのを確認しました:

これが励みであるが、私は /apiman-echoエンドポイントと最初apiman GUIのAPIをセットアップするため、間に衝突があることを懸念してい

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 
} 

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

このは、得られたカールの結果でしたそれとmavenのプロセスを通して作成したエンドポイントですが、わかります。

関連する問題