Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Jarhakoz's avatar

PHP Soap client response vs. Python Zeep

I use Soap client to make a call and then return the result as Collection. Using Python and Zeep, float values are returned as floats, but PHP's __soapCall('GetSomeService', $params) is returning strings, which is super annoying. Nice thing is that Laravel's API converts the collection automatically to JSON. This float comes as a string directly from __soapCall(), so it's not a Lavavel problem exactly. Python also has a nice conversion jo JSON, whera floats are decimal numbers, not "strings", so 10.000 is not "10.000".

0 likes
3 replies
Jarhakoz's avatar

Yep, Python is returning the number 10.000 (from soap) in JSON as number 10 and 10.500 as 10.5. Is there a way to configure Laravels automatic json conversion to use always setting JSON_NUMERIC_CHECK, from a application wide setting? I don's see anything json related in config/ folder? I want to use a app wide setting, and not manually do return collect($data)->toJson(JSON_NUMERIC_CHECK);

Jarhakoz's avatar

PHP Classes generated by wsdl2phpgenerator does not correctly add types, it simply generates

/**
 * @var float $price
 */
public $price=null;

When it should generate, (so JSON conversion works automatically with correct types)

/**
 * @var float|null $price
 */
public ?float $price=null;

Please or to participate in this conversation.