duangan6731 2012-04-11 21:37
浏览 70

在PHP中处理Webservice流

Good day guys.

I need to consume a webservice that works as a file streaming (it receives a file Id and returns the file via stream).

Then in PHP I must handle this process. I have been looking for a solution on how to do this since, as far as I know, the native soap client in PHP does not have these capabilities.

I found WSO2 (Web Services Framework for PHP) which handles Binary attachment ( MTOM ).

I'm yet to test it, but the real question is, based on your experience, what would be the smartest approach for consuming a webservice with these characteristics?

Thank you very much for your time.

  • 写回答

1条回答 默认 最新

  • douzhiji2020 2012-04-11 23:27
    关注

    WSO2 WSF/PHP is a better more sophisticated of doing file streaming using MTOM which is a standard that other languages support.

    MTOM uses base64 to encode files which you can implement on your on if you don't want yo use WSO2

    Am not sure why you want stream please note that you can always open any file asstream so far you have a copy of that files so i don't think that is the most important .. what is key is sending the file safely to the server

    Example using SoapClient

    Client

    ini_set("soap.wsdl_cache_enabled", "0");
    $client=new SoapClient(PATH_TO_WSDL,array('encoding'=>'ISO-8859-1'));
    $data = file_get_contents(PATH_TO_FILE);
    $ret = $client->recieveFile(base64_encode($data));
    

    Server

    ini_set("soap.wsdl_cache_enabled", "0");
    
    const  PATH_TO_WSDL = "b.php?wsdl" ;
    $client=new SoapClient(PATH_TO_WSDL,array('encoding'=>'ISO-8859-1'));
    $data = file_get_contents(PATH_TO_FILE);
    $ret = $client->recieveFile(base64_encode($data));
    

    Please note that base64 would increase the file by 33% it advisable to spit the files into chunks for very large files

    评论

报告相同问题?

悬赏问题

  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R
  • ¥15 在线请求openmv与pixhawk 实现实时目标跟踪的具体通讯方法
  • ¥15 八路抢答器设计出现故障
  • ¥15 opencv 无法读取视频
  • ¥15 按键修改电子时钟,C51单片机
  • ¥60 Java中实现如何实现张量类,并用于图像处理(不运用其他科学计算库和图像处理库))