替代通过文档文字的SOAP用base64发送图像 [英] Alternatives to sending an image in base64 via document literal SOAP

查看:191
本文介绍了替代通过文档文字的SOAP用base64发送图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我正在修改一个商业应用文档文字的SOAP服务,关于客户来回传输数据。

I'm currently modifying a document literal SOAP service for a business app which transfers data about customers backwards and forwards.

传送扫描的文档图像的新要求刚刚被确定。我的问题是,我用的是专有的语言不支持SOAP附件。

A new requirement to transfer scanned document images has just been identified. The problem I have is that the proprietary language I use does not support SOAP attachments.

图像传送可以是任何高达32KB。

The images being transferred can be anything upto 32KB.

我能想到的唯一的办法是为Base64 EN code中的图像,并通过将它作为XML文档的一个元素。

The only solution I can think of is to base64 encode the image, and pass it through as an element of the XML document.

这感觉就像一个非常糟糕的主意,但我想不出更好的东西。

This feels like a really bad idea, but I just can't think of anything better.

任何想法?

编辑:我忘了提,图像没有在文件系统远程举行,它被存储在Oracle数据库中,这是我没有直接连接到的能力,

I forgot to mention that the image isn't held remotely in a file system, it is stored in an Oracle database, which I do not have the ability to connect directly to,

推荐答案

如果你使用XML作为数据传输机制,必须设有code在某些方面的形象。其原因是,XML是文本格式,和XML处理器将试图去code的二进制数据,就好像它是文本(更具体地,如同除非指定不同的编码是UTF-8)。此外,XML明确禁止几个字符(ASCII大部分非printables为XML 1.0,\\ u0000的对XML 1.1),所以你会破坏你的数据,如果你只是转储图像数据转换成(说)CDATA节。

If you're using XML as a data transfer mechanism, you have to encode the image in some way. The reason is that XML is a text format, and an XML processor will attempt to decode binary data as if it's text (more specifically, as if it's UTF-8 unless you specify a different encoding). Moreover, XML explicitly disallows several characters (most ASCII non-printables for XML 1.0, \u0000 for XML 1.1), so you'll corrupt your data if you just dump the image data into (say) a CDATA section.

编辑:XML模式定义了一个base64Binary的类型,所以你应该能够定义您的WSDL适当的(假设你正在使用一个自动化的编组)。至少,你应该使用的xsi:type包含的元素属性上EN codeD的内容。

XML Schema defines a "base64Binary" type, so you should be able to define your WSDL appropriately (assuming that you're using an automated marshaller). At the least, you should use an "xsi:type" attribute on the element containing your encoded content.

这篇关于替代通过文档文字的SOAP用base64发送图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆