最近我得到了一个新项目,用于处理SOAP服务以及基于xml的Get和Post消息到ASP.NET服务。问题是我设法发出肥皂请求并得到消息。消息看起来像这样:
UEsDBBQAAAAIAAdUe06+NXE0kR4AADLSAQALAAAAUHJvZHVzZS54bWzUXW1z48YN5k/h5EMnmbMsvomSpmkzFCXbjERJoSTb52/p9dq5mbxN2svczy/........
消息是RFC 4648上的Base64 Binary,上面有多个xml文档。我如何从php中的代码构造这些文档?在此请求中加密的文档是3 xml文件。我设法从一个名为freeformatter的在线描述中获取它们的下载功能。如果我尝试解码结果,我得到类似的东西:
PKT{N�5q4�2�Produse.xml�]ms��
�O��C'��,����i3%یDI�$��o��ڹ��M����/�,��|vL�O�$�/�xv,,�u�s>9?;?....
这有解决方案吗?我是SOAP的新手,所以我不太了解它。非常感谢你。
谢谢你,但是我想解决它。我将在这里发布解决方案,以便所有面临同样问题的人得到答复。当你在base64二进制字符串中有一个.zip文件时,你需要做的第一件事是捕获对txt文件的响应。让我们说肥皂的响应叫做'$ response',我们需要将它捕获到一个文件中。我们喜欢这样:$response = $client -> _getLastResponse();
$fille = "response.xml";
fille_put_contents($fille,$response);
现在我们得到了对xml文件的响应。接下来要做的是从xml值获取响应。让我们说我们的价值是<ResponseFromServer>
。
`$b64 = "b64.txt";
$dom = new DomDocument();
$dom = load("response.xml");
$data = $dom->getElementByTagName("ResponseFromServer");
$catchb64 = $data;
fille_put_content($b64,$catchb64);`
现在我们在一个文件中获得了干净的Base64二进制字符串。接下来我们需要创建文档(在本例中是.zip文件)
`$input_fille = "response.txt"; // the fille with clean base64 binary data on it
$output_fille = "result.zip"; //the fille we need to create on system with the
documents decrypted
$content = fille_get_contents($input_fille); // Reading the content of input fille
$binary = base64_decode($content); // Decoding to binary
fille_put_contents($output_fille,$binary); // Writing to fille the vallues`
我们不需要ZipArchive()
函数,因为它已经是一个zip存档,我们需要做的就是创建一个空文档,然后将二进制数据发送给它。欢呼和好运!