duanhuchang5056 2012-06-07 14:49
浏览 25
已采纳

too long

I am using System.Net.WebClient client in .NET to post parameters for PHP web service. The PHP works and creates a file. How can i force the .NET client to wait to that file from php and get it.

  1. How would be better for the php to send it exatly to the service that called him?
  2. how can i wait for that file in my .Net client?
  • 写回答

1条回答 默认 最新

  • donglinxi1467 2012-06-07 16:02
    关注

    In PHP, do what You need to be able to create a file. Then create that file, get it contents and base64_encode the data. Create an XML (e.g.) and put in the filename, file mime_type and base64 encoded data...

    It could look like this (supposing the file is already created and stored somewhere in temp, the filename is stored in variable $my_filename_with_extension and its mime_type is stored in variable $my_file_mime_type - should You ever need it...):

    $data = base64_encode(file_get_contents(TEMP_DIR.$my_filename_with_extension));
    $xml = '<'.'?xml version="1.0" encoding="UTF-8" ?'.'>';
    $xml .= '<response>
        <filename>'.$my_filename_with_extension.'</filename>
        <mime_type>'.$my_file_mime_type.'</mime_type>
        <data>'.$data.'</data>
    </response>';
    echo $response;
    

    Then in .NET application parse that XML and do whatever You need to do with the file data (base64 decode it to get the original file data).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥188 寻找能做王者评分提取的
  • ¥15 matlab用simulink求解一个二阶微分方程,要求截图
  • ¥30 乘子法解约束最优化问题的matlab代码文件,最好有matlab代码文件
  • ¥15 写论文,需要数据支撑
  • ¥15 identifier of an instance of 类 was altered from xx to xx错误
  • ¥100 反编译微信小游戏求指导
  • ¥15 docker模式webrtc-streamer 无法播放公网rtsp
  • ¥15 学不会递归,理解不了汉诺塔参数变化
  • ¥15 基于图神经网络的COVID-19药物筛选研究
  • ¥30 软件自定义无线电该怎样使用