0

MultipartEntityとFormBodyPartを使用してマルチパートリクエストを作成するHTTPクライアントを構築しています。ただし、リクエスト本文自体にXMLコンテンツを追加する方法がわかりません。最後に、リクエストは次のようになります。

--ejjeeffe0
request-id: 99f9a899-5e25-45fb-9faa-d92320f60f7e
content-length: 1915
Function: CORE
content-type: text/xml
request-type: data
some-other header attributes: values

<?xml version="1.0" encoding="utf-8"?>
<xml payload here>

--ejjeeffe0
request-id: b7612e0a-b117-4ad7-a11f-2ea5a7e5fdc1
request-type: statistical_record
content-type: text/plain
content-length: 0
some-other attributes: values

--ejjeeffe0--

FormBodyPartには、本体自体に追加するメソッドがないようです。助言がありますか?

4

1 に答える 1

0

私が何かを見逃していない限り、それはかなり些細なはずです

entity.addPart(new FormBodyPart("my-text", new StringBody(somestring)));
entity.addPart(new FormBodyPart("my-data", new FileBody(somefile)));
于 2012-10-12T15:55:47.540 に答える