【问题标题】:Soap BAD_REQUEST cannot parse templateSoap BAD_REQUEST 无法解析模板
【发布时间】:2020-05-10 14:51:32
【问题描述】:

我使用 WSDL 文件来发送短信,我使用 Wsdl2PhpGenerator\Generator 生成了所有 php 类。 如您所见,其中一个函数作为参数@param base64Binary $tpl 获取,该参数的类型是base64Binary。

我一直在尝试对我的 $tpl 进行编码,但没有任何运气

$tpl = __DIR__ . "/file00000"
$content = file_get_contents($tpl);
$src =  base64_encode($content);

编码后的结果数据以:

开头
"SVMtQgAAAAFIRUFEAAAABAAAAAhGSUxFAA ...

这是我的收获 (\SoapFault $e)

{#355 ▼
      +"code": "BAD_REQUEST"
      +"desc": "cannot parse template"
    }

你有什么想法吗?

【问题讨论】:

    标签: php soap base64 soap-client


    【解决方案1】:

    Base64 是一个字符串,不是二进制的。

    如果您的 WSDL 文件需要参数 base64Binary 类型,请不要使用base64_encode(),因为 PHP Soap 会自己进行编码。

    您可以将$content 直接传递为$src

    【讨论】:

      猜你喜欢
      • 2018-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多