java编码的base64肥皂附件
这是我的第一篇文章,我真的很困惑。这是我需要做的:我正在使用 axis2 编写一个 java web 服务客户端来生成代理,并且我正在尝试发送附件。附件必须由 base64 编码,并且代理正在调用数据处理程序。我一直在使用 MimeUtility.encode 来创建编码,但数据处理程序不喜欢输出流。数据处理程序仅处理字符串,但该字符串在服务器端未正确解释。如果你能给我一些指导,我已经为此工作好几天了。这是我的错误代码,现在它不读取数据处理程序,但希望它说明了我需要做什么:
int BUFFER_SIZE = 4096;
byte[] buffer = new byte[BUFFER_SIZE];
InputStream input = new FileInputStream("C:/test.docx");
OutputStream encodedOutput = MimeUtility.encode(new ByteArrayOutputStream(), "base64");
int n = input.read(buffer, 0, BUFFER_SIZE);
while (n >= 0) {
encodedOutput.write(buffer, 0, n);
n = input.read(buffer, 0, BUFFER_SIZE);
}
DataHandler dhandle = new DataHandler(encodedOutput, "base64");
This is my first post and i'm really stuck. Here is what i need to do: I'm writing a java web service client using axis2 to generate the proxies and i'm trying to send an attachment. The attachment must be encoded by base64 and the proxy is calling for a datahandler. I've been using MimeUtility.encode to create the encoding but the datahandler does not like the output stream. The datahandler has only worked with a string but the string is not interperted correctly on the server side. If you can give me some direction i've been working on this for days. Here is the bad code i have, right now it does not read the data handler but hopefully it illustrates what i need to do:
int BUFFER_SIZE = 4096;
byte[] buffer = new byte[BUFFER_SIZE];
InputStream input = new FileInputStream("C:/test.docx");
OutputStream encodedOutput = MimeUtility.encode(new ByteArrayOutputStream(), "base64");
int n = input.read(buffer, 0, BUFFER_SIZE);
while (n >= 0) {
encodedOutput.write(buffer, 0, n);
n = input.read(buffer, 0, BUFFER_SIZE);
}
DataHandler dhandle = new DataHandler(encodedOutput, "base64");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论