【问题标题】:Delphi SOAP Server with file attachment and PHP as Client带有文件附件和 PHP 作为客户端的 Delphi SOAP 服务器
【发布时间】:2012-07-27 09:08:38
【问题描述】:

我正在寻找可以在 PHP 和 Delphi Soap Server 之间进行集成的解决方案。我想通过 PHP Soap Client 将文件发送到 Delphi SOAP Server。 Delphi 服务器代码将使用 TSoapAttachment 调用,示例代码如下:-

Ttextminesvc = class(TInvokableClass, Itextminesvc)
  public
 .....
  protected
      function UploadFile(afilename: string; afile: TSoapAttachment): Boolean;
      stdcall;

....... 

function Ttextminesvc.UploadFile(afilename: string; afile: TSoapAttachment): Boolean;
var ffilename: string;
const pathdir = 'C:\tmp';
begin
  result := false;
  ffilename := pathdir + afilename;
  try
    if not directoryexists(pathdir) then
      ForceDirectories(pathdir);
  except
    raise Exception.Create('Unable to create repository directory on the server.');
  end;
  try
    if not fileexists(ffilename) then
    begin
      afile.SaveToFile(ffilename);
      result := true;
    end;
  except
    result := false;
  end;
end;

谢谢

【问题讨论】:

  • 所以您的实际问题是“如何使用 PHP SOAP 客户端发送文件附件”?
  • 相关:stackoverflow.com/questions/1529263/…。对 Google 的简短讨论表明,如果不为 PHP 滚动您自己的 SOAP 客户端,这根本是不可能的,但我很高兴在这件事上被证明是错误的。
  • 是的,使用 PHP 向 Delphi SOAP Server 发送文件。我在使用函数 UploadFile(afilename: string; afile: TSoapAttachment) 时遇到问题。如何在 PHP 中处理 TSoapAttachment?
  • 这表明它可以用 NuSOAP 完成:stackoverflow.com/questions/2913106/php-soap-transfering-files - 我现在阅读的关于这个主题的许多帖子的普遍共识似乎是它不能用 PHP 原生 SOAP 客户端完成.

标签: php delphi soap


【解决方案1】:

来自另一个 SO 帖子 (http://stackoverflow.com/questions/3663416/php-soap-file-upload):
“你可以传输任何你喜欢的数据。你只需要对二进制数据进行base64编码。它将它转换为ascii字符。然后你可以像普通的字符串变量一样传输它。唯一需要注意的是服务器限制。 "

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-28
    • 1970-01-01
    • 1970-01-01
    • 2012-12-07
    • 1970-01-01
    相关资源
    最近更新 更多