【发布时间】:2015-12-03 02:26:10
【问题描述】:
我正在关注链接 https://access.redhat.com/documentation/en-US/OpenShift_Enterprise/2/pdf/REST_API_Guide/OpenShift_Enterprise-2-REST_API_Guide-en-US.pdf 构建我的 rest api java 应用程序,它将一个 WAR 二进制文件从 Web 位置部署到我的帐户中。
我得到了
InboundJaxrsResponse{context=ClientResponse{method=POST, uri=https://openshift.redhat.com/broker/rest/application/#{myAppID}/deployments, status=422, reason=Unprocessable Entity}} 作为响应:
#{myAppID} 是我为安全起见在此处替换的应用程序 uuid
我正在使用 glassfish rest api,我的代码是:
String url_of_war = "https://code.google.com/p/web-actions/downloads/detail?name=helloworld.war";
WebTarget webtarget;
Client client
HostnameVerifier hostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
};
client = ClientBuilder.newBuilder().sslContext(trustAllCertificates()).hostnameVerifier(hostnameVerifier ).build();
}
URIBuilder uriBuilder = new URIBuilder();
try {
uriBuilder = uriBuilder.setScheme("https").setHost("openshift.redhat.com/broker/rest/").setPath("application/#{myAppId}/deployments");
if (getPort() > 0) {
uriBuilder = uriBuilder.setPort(getPort());
}
URI uri = uriBuilder.build();
webtarget = client.target(uri);
} catch (Exception e) {
String msg = "Could not build URI!";
throw new RuntimeException(msg, e);
}
Invocation.Builder invocationBuilder = webtarget.request(MediaType.APPLICATION_JSON_TYPE).accept(MediaType.APPLICATION_JSON_TYPE);
invocationBuilder.header("Authorization", "Basic "+Base64.encodeBase64String("#{myuser}:#{mypass}".getBytes()));
Form form = new Form();
form.param("hot_deploy", "false");
form.param("force_clean_build", "false");
form.param("artifact_url", URLEncoder.encode(url_of_war, "UTF-8"));
Response response = invocationBuilder.post(Entity.form(form));
我在这里做错了什么,自从 30 天以来,我一直在这个问题上没有任何线索,我还尝试创建与 openshift/jboss 兼容的部署文件夹,我在其中放置了 war 文件并可以作为压缩的 .tar 下载.gz 文件但同样的问题 非常感谢您的帮助。 谢谢
【问题讨论】:
-
更正一下,我使用的war url是:String url_of_war = "web-actions.googlecode.com/files/helloworld.war";