Alternatives to sending an image in base64 via document literal SOAP

点点圈 提交于 2019-12-06 00:57:12

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.

Edit: 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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!