RemoteConverter
jBoss Web アプリケーションから、server-standalone
documents4j プロジェクトに含まれるデフォルトとして構築されたスタンドアロン サーバーまでを使用しています。
jboss 内には必要なライブラリhttpclient-4.0.1.jar
と関連の古いバージョンがあるため、JVM によってロードされた jar の異なるバージョンが原因httpcore-4.0.1.jar
で多くの問題に直面しています。ClassDefNotFoundException
HttpClientConnectionManager
バージョンでまだ使用できないオブジェクトに特定の問題があります
この問題を回避するために、 用のカスタム http クライアントを構築したいと考えています。standalone-server
以前の問題により、 を使用できないからJersey
です。
誰かがそのために別のクライアントを構築しましたstandalone-server
か? カスタムを構築するための仕様は何RemoteClient
ですか?
更新 1
スニッフィングツールを使用して少し分析した後、メッセージの構成を把握したので、HttpClient
そのサーバーのカスタムを次のように終了しました。
File wordFile = new File("C:/temp/test.docx");
InputStream targetStream = new FileInputStream(wordFile);
URL url = new URL("http://localhost:9998");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/vnd.com.documents4j.any-msword");
conn.setRequestProperty("Accept", "application/pdf");
conn.setRequestProperty("Converter-Job-Priority", "1000");
OutputStream os = conn.getOutputStream();
os.write(IOUtils.toByteArray(targetStream));
os.flush();
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));
FileWriter ostream = new FileWriter("C:/temp/test.pdf");
BufferedWriter out = new BufferedWriter(ostream);
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
out.write(output+"\n");
}
br.close();
out.close();
os.close();
conn.disconnect();
作成したばかりのtest.pdfファイルを開こうとすると、すべて白ですが、ページ数は適切です。テキスト エディターでファイルを開き、ファイルの先頭と末尾を分析すると、次の文字が見つかりました。
%PDF-1.5
%µµµµ
1 0 obj
[...]
startxref
1484122
%%EOF
PDFファイルが良さそうです。
REST サーバーから受け取ったそのファイルと何か関係がありますか?