duanjiagu0655 2013-02-21 00:20
浏览 42

如何通过XML传输PHP数组?

I have an XML document that is encrypted using a proprietary encryption program like so: exec($programName, $outputArr, $returnVal);

The resulting array ($outputArr) was serialized and stored as a blob in MySQL. I was making this encrypted array available on demand through a web interface. Basically deserializing and writing to a file on the fly.

Now the requirements have changed and I need to make this encrypted array available to another server which uses .net/c# and which in turn will host the web interface. We are using a REST API that responds to a GET request and sends out an XML response.

I tried writing the array into a temporary file and then retrieving the contents of the file using file_get_contents($tempFile) and then URL encoding the resulting string and putting that inside of the XML response that I was sending.

Of course, when the new web interface writes this out as a file (after URL decoding), it's nothing like it's supposed to be. By that, I mean our proprietary program throws up errors on reading this new resulting file ... somewhere along the way, there's data corruption happening.

We also tried a C# serialization library that deserialized PHP arrays into a c# primitive type but that wasn't a good solution either as it kept throwing up a bunch of errors.

Is there a better way to do this?

  • 写回答

1条回答

  • dongtaogu8510 2013-02-21 00:25
    关注

    Why not just access the working version, and re-manipulate it before sending to the new server...

    <!-- Some XML based wrapper or other logic/output -->
    <?php
      echo file_get_contents($url_to_working_web_interface);
    ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗