6

到目前为止,我一直在使用简单的 base64 编码发送带有 SOAP 的附件并将它们内联——所有这些都由 CURL 完成。现在我有一个新请求,附件需要作为 MTOM 附件发送,问题是:linux curl 可以吗?可能我需要一个multipart/related或类似的内容类型。

我可以看到使用 JAX-WS 是可能的,但为了做到这一点,我们必须开发一个新客户端,这实际上不是我们的最佳选择。

请告诉我是否可能,如果是,请给我任何提示如何做到这一点。

4

1 回答 1

0

您可以将文件内容包含在 base64 编码中并使用 curl post。

这是一个例子:

  1. 安装了来自axis2的mtom示例并为您工作
  2. 构造以下示例 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>
  1. 使用 curl 发布请求

$ 猫 req.xml | curl -X POST -H '内容类型:应用程序/soap+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>

这对你有用吗?

于 2013-02-25T02:05:23.453 回答