Java 使用SOAP消息发送图像
我想把我的JPG添加到我的SOAP请求中,我想我需要转换它 当我使用SoapUI发送相同的soapMessage(它可以工作)时,我可以看到我的图像编码如下:Java 使用SOAP消息发送图像,java,xml,soap,encoding,Java,Xml,Soap,Encoding,我想把我的JPG添加到我的SOAP请求中,我想我需要转换它 当我使用SoapUI发送相同的soapMessage(它可以工作)时,我可以看到我的图像编码如下: [0xff][[0xff][[0xff][[0x杰夫][[0x杰夫][[0x杰夫][[0x杰夫][[0x杰夫][[0x0[0xff][[0x杰夫][[0x杰夫][[0x杰夫][[0x杰夫][[0x杰夫][[0x杰夫][[0x0[0x杰夫][[0x0][[0x0][[0x0[0x0][[0x0[0x0[0x0[0x0][[0x0[0x0[0
[0xff][[0xff][[0xff][[0x杰夫][[0x杰夫][[0x杰夫][[0x杰夫][[0x杰夫][[0x0[0xff][[0x杰夫][[0x杰夫][[0x杰夫][[0x杰夫][[0x杰夫][[0x杰夫][[0x0[0x杰夫][[0x0][[0x0][[0x0[0x0][[0x0[0x0[0x0[0x0][[0x0[0x0[0x0 0 0 0[0x0[0x1][0x1][][[0x1][0x1][[0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][0x1][][0x0][0x0][0x0][0x9e][0x1][0x10][0x0][0x2][0x2][[0x2][0x0][][0x0[0x0]][0x0[0x2][0x0[0x2][0x0[[0x2][0x0[[0x0][[0x2][0x0][0x0][0x0[0x0][0x0[0x0][0x0[0x0]][0x0[0x0][[0x0][0x0][0x0[0x0[0x0][[0x0][0x0][0x0][0x0][0x0[0x0]][0x0][0x0][0x0][0x0][0x0][0x0][0x0[0x0][0x0]][0x0][0x0][0x0][0x0][0x0[0x0]][0x0][0x0][0x0][0x0][0x0][0x0][0x0][0x0][0x0[0x0[[0x0][0x0][0x0][0x0][0x0][0x0][0x0][0x0][0x0][0x0][0x00x0][0xc][0x0][0x0][0x0][0xbe][0x1][0x0 0 0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0 0 0 0 0[0 0 0 0 0 0 0 0 0[0x0[0 0 0 0[0 0 0[0 0 0 0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0 0 0][00 0 0][00 0 0 0 0][0][00 0 0[0x0 0 0 0 0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0[0x0][0][0[0x0[0x0[0x0[0x0][0][0][0][0][0[0x0[0x0][0][32:04[0x0][0x0][0x1c][0x82][0x9a][0x0][0x5][0x0][0x0][0x0][0x1][0x0][0x0][0x0][0x2]4[0x82][0x9d][0x0][0x5][0x0][0x0][0x1][0x0][0x0][0x2]要使用SOAP发送图像,必须使用以下格式之一进行编码:
- Base64二进制
- SwA-带附件的肥皂
- MTOM
<submitClaim>
<accountNumber>5XJ45-3B2</accountNumber>
<eventType>accident</eventType>
<image imageType="jpg" xsi:type="base64binary">
4f3e9b0...(rest of encoded image)
</image>
</submitClaim>
向我们展示你迄今为止所做的尝试。这里没有人会为你做所有的工作。即使是关于所用堆栈等的更多信息也会有所帮助。看看这里,我在一周内尝试过,但我不放任何代码行,因为我想看到其他想法。谢谢你的帮助。谢谢你的帮助。当我在Base64中编码我的图像时,它起作用了,我把这个编码放进了介于
public static String encodeToString(BufferedImage image, String type) {
String imageString = null;
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
ImageIO.write(image, type, bos);
byte[] imageBytes = bos.toByteArray();
BASE64Encoder encoder = new BASE64Encoder();
imageString = encoder.encode(imageBytes);
bos.close();
} catch (IOException e) {
e.printStackTrace();
}
return imageString;
}