Bug Report Template
Description
file_get_file_contents always returns raw binary instead of base64 when requesting raw=false via SOAP.
This causes SOAP parsing to fail with UTF-8 errors when retrieving images or other binary files.
The issue happens regardless of whether parameters are sent using the WSDL-defined names (file, raw) or the positional parameters (param0, param1).
I am using soap apis from my apiscp server on :2083/soap, and calling them on my node js app.
It appears the SOAP handler is not interpreting the raw parameter correctly, and defaults to raw = true, returning binary data.
Steps to Reproduce
Attempt 1 — Using WSDL-specified parameters
SOAP Body:
<tns:file_get_file_contents>
<file>/home/user/image.jpg</file>
<raw>false</raw>
</tns:file_get_file_contents>
Attempt 2 — Using positional parameters
SOAP Body:
<tns:file_get_file_contents>
<param0>/home/user/image.jpg</param0>
<param1>false</param1>
</tns:file_get_file_contents>
Result
ApisCP returns raw binary bytes (JPEG header 0xFF 0xD8 0xFF ...) inside XML.
SOAP parser immediately fails with:
SOAP-ERROR: Encoding: string '\xff...' is not a valid utf-8 string
This means ApisCP is not honoring raw=false.
Expected Behavior
When raw=false, based on ApisCP internal implementation:
return $raw ? $contents : base64_encode($contents);
we expect:
- SOAP response containing base64-encoded file contents
- No invalid UTF-8 errors
This is necessary for downloading images, videos, or other binary files safely via SOAP.
Actual Behavior
ApisCP returns raw binary contents to the SOAP client even when:
<raw>false</raw>is sent, or<param1>false</param1>is sent
This results in invalid UTF-8 sequences inside XML:
SOAP-ERROR: Encoding: string '\xff...' is not a valid utf-8 string
The behavior suggests the raw argument is not being interpreted as a boolean by the SOAP dispatcher.
Environment
Additional Information
WSDL Fragment
<message name="file_get_file_contents_request">
<part name="file" type="xsd:anyType" />
<part name="raw" type="xsd:anyType" />
</message>
<message name="file_get_file_contents_response">
<part name="return" type="xsd:string" />
</message>
Actual PHP implementation
From ApisCP source:
return $raw ? $contents : base64_encode($contents);
This confirms:
raw=true→ return binaryraw=false→ return base64
Yet even with raw=false passed through SOAP, ApisCP behaves as if raw=true.
Error Message
SOAP-ERROR: Encoding: string '\xff...' is not a valid utf-8 string