简体   繁体   English

php,如何从SOAP MTOM附件解码/保存文件?

[英]php , How to decode / save a file from SOAP MTOM attachment?

I'm trying to get the content / save a zipfile returned by a webservice . 我正在尝试获取内容/保存由Web服务返回的zipfile。 However It seems that the API provides the file encoded in Base64 Binary format and included in the response according to the SOAP MTOM standard. 但是,似乎该API提供了以Base64 Binary格式编码的文件,并根据SOAP MTOM标准将其包括在响应中。 I've tried some workarounds for 2 hours so any help would be highly appreciated . 我已经尝试了2个小时的解决方法,因此任何帮助将受到高度赞赏。 The response looks like this : 响应如下所示:

--MIMEBoundaryurn_uuid_9ADB5E0C3BD2353F98133706376435374151
Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:9ADB5E0C3BD2353F98133706376435374152>
<?xml version='1.0' encoding='UTF-8'?><downloadFileResponse xmlns="http://www.pe.com/marketplace/services"><ack>Success</ack><version>1.1.0</version><timestamp>2012-05-15T06:36:04.353Z</timestamp><fileAttachment><Size>3204907</Size><Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:FED4FAD1B1E74C8B391337063821260"/></Data></fileAttachment></downloadFileResponse>

--MIMEBoundaryurn_uuid_9ADB5E0C3BD2353F98133706376435374151
Content-Type: application/zip
Content-Transfer-Encoding: binary
Content-ID: <urn:uuid:FED4FAD1B1E74C8B391337063821260>
here is some messy code   ADASLKDAKDNAKJDNAKDNKJNDSAKDJNAKDJADA which is actually the file content itself

I hope this helps someone ... I simply removed all the markup code/mime type xml etc before the messy characters and saved the content as a .zip file . 我希望这对某人有帮助...我只是在混乱字符之前删除了所有标记代码/ MIME类型xml等,并将内容另存为.zip文件。 It's not an ideal solution but it works. 这不是理想的解决方案,但可以。

--MIMEBoundaryurn_uuid_9ADB5E0C3BD2353F98133706376435374151
Content-Type: application/xop+xml; charset=utf-8; type="text/xml"
Content-Transfer-Encoding: binary
Content-ID: <0.urn:uuid:9ADB5E0C3BD2353F98133706376435374152>
<?xml version='1.0' encoding='UTF-8'?><downloadFileResponse xmlns="http://www.pe.com/marketplace/services"><ack>Success</ack><version>1.1.0</version><timestamp>2012-05-15T06:36:04.353Z</timestamp><fileAttachment><Size>3204907</Size><Data><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:urn:uuid:FED4FAD1B1E74C8B391337063821260"/></Data></fileAttachment></downloadFileResponse>

--MIMEBoundaryurn_uuid_9ADB5E0C3BD2353F98133706376435374151
Content-Type: application/zip
Content-Transfer-Encoding: binary
Content-ID: <urn:uuid:FED4FAD1B1E74C8B391337063821260>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM