English 中文(简体)
如何发送 MIME 多个部分的闲散请求, 以 java 中不同内容类型发送 。
原标题:How to send mime multipart restful request with different content types in java

我有很多要求xml和/或base64编码的图像, 我要把它发送到客户端服务器, 它们有他们的 REST API 。 还需要将多个请求合并到一个请求中, 才能有效地使用带宽 。 所以我正在考虑使用 mime- plus 请求 。 我可在 java 中使用哪些图书馆来完成这个请求 。 我知道如何在 java 中发送常规的 http unclication, 但我不知道如何发送多部分 mime 请求? 也就是说, 我将如何为每个身体指定不同的内容类型? 是否希望有任何指针 。

我想送这种东西

Content-type: multipart/form-data;boundary=main_boundary

--main_boundary
Content-type: text/xml
<?xml version= 1.0 ?>
<content>
Some content goes here
</content>

--main_boundary
Content-type: multipart/mixed;boundary=sub_boundary

--main_boundary
Content-type: text/plain; charset=utf-8

 {base64 encoded string that represents image}

--main_boundary--

如果我理解错误,请随意纠正我。这是我第一次使用MIME。

问题回答

Apache HttpClient 库可以帮助您构建多部分文件上传请求 。

请查看re。这里是http://svn.apache.org/viewvc/httpsublicts/oac.hc3x/trunk/src/examples/MultipartFileUploadApp.java?view=markup>





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签