您可以使用base64編碼並使用curl post來包含文件內容。
下面是一個例子:
- 有從安裝Axis2的MTOM樣本,爲你工作
- 構建下面的示例req.xml
$貓req.xml
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:mtom="http://ws.apache.org/axis2/mtomsample/" xmlns:xm="http://www.w3.org/2005/05/xmlmime">
<soap:Header/>
<soap:Body>
<mtom:AttachmentRequest>
<mtom:fileName>one.txt</mtom:fileName>
<mtom:binaryData xm:contentType="application/txt">SSBhbSB0aGUgZ3JlYXRlc3Qu</mtom:binaryData>
</mtom:AttachmentRequest>
</soap:Body>
</soap:Envelope>
- 發佈使用請求curl
$ cat req.xml |捲曲-X POST -H '內容類型:應用程序/肥皂+ XML' -d @ -
http://yourmachine.com:8080/axis2/services/MTOMSample.MTOMSampleSOAP12port_http/
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<ns2:AttachmentResponse xmlns:ns2="http://ws.apache.org/axis2/mtomsample/">
File saved succesfully.
</ns2:AttachmentResponse>
</soapenv:Body>
</soapenv:Envelope>
這是否對你的工作?