【发布时间】:2014-01-04 20:53:34
【问题描述】:
我们正在使用 SOAP Web 服务向我们的客户发送交易。
我们的环境:
容器:无(组件独立运行) 轴版本:1.6.2
要求:
如果交易规模较小,我们需要将内容作为 Body 的一部分发送。 如果交易量很大,需要将内容作为附件发送。
代码 sn-p:
final ServiceClient sender = new ServiceClient();
final Options options = new Options();
options.setTo(endpointRef);
options.setTransportInProtocol(Constants.TRANSPORT_HTTP);
options.setProperty(Constants.Configuration.ENABLE_MTOM,Constants.VALUE_TRUE);
sender.setOptions(options);
final OMFactory omFactory = OMAbstractFactory.getOMFactory();
.
.
.
DataHandler dataHandler = new DataHandler(new FileDataSource(new File("C://KB_9.9.xml")));
OMText omText = omFactory.createOMText(dataHandler, true);
final OMElement inputData = omFactory.createOMElement("inputData",null);
inputData.addChild(omText);
method.addChild(inputData);
sender.fireAndForget(omElement);
我们的问题:
它工作正常,数据成功到达。但问题是附件未编码。它按原样显示文件的内容。我的问题是我们是否需要启用轴的任何属性来编码附件内容,或者我们需要手动执行 Base64 编码。
样本输出:
***--MIMEBoundary_5e6b57717e6fc299242f9cc2ec3ab3d6cd5ef851033370e3***
Content-Type: application/xop+xml; charset=UTF-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.d5d9e693c8e32f0069b7cbb392d60e7f8b08366c7cb4384d@apache.org>
<?xml version='1.0' encoding='UTF-8'?>
xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1.7e6b57717e6fc299242f9cc2ec3ab3d6cd5ef851033370e3@apache.org"
***--MIMEBoundary_5e6b57717e6fc299242f9cc2ec3ab3d6cd5ef851033370e3***
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary
Content-ID: <1.7e6b57717e6fc299242f9cc2ec3ab3d6cd5ef851033370e3@apache.org>
My test file.....
***--MIMEBoundary_5e6b57717e6fc299242f9cc2ec3ab3d6cd5ef851033370e3--***
你能帮我解决这个问题吗
【问题讨论】: