当前位置: 动力学知识库 > 问答 > 编程问答 >

java encoded base64 soap attachment

问题描述:

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");

分享给朋友:
您可能感兴趣的文章:
随机阅读: