Search code examples
phpsoapbase64soap-client

Soap BAD_REQUEST cannot parse template


I am using a WSDL file in order to send the sms, i generated all the php class by using Wsdl2PhpGenerator\Generator. One of the functions get as paramers @param base64Binary $tpl as you see the type of this parameter is base64Binary.

I've been trying to encode my $tpl without any luck

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

The encoded result data starts with:

"SVMtQgAAAAFIRUFEAAAABAAAAAhGSUxFAA ...

This is my catch (\SoapFault $e)

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

Do you have any idea?


Solution

  • Base64 is a string not binary.

    If your WSDL file wants a parameter base64Binary type, do not use base64_encode(), because PHP Soap does the encoding by itself.

    You can pass $content directly as $src.