I'm writing a PHP wrapper for a SOAP service and using the class map option so I can work with objects instead of arrays. This works great until the provider of the SOAP service decides to add a new property to one of their objects (which they seem to like doing without telling anyone) at which point the SOAP client breaks with the error SOAP-ERROR: Encoding: object has no 'NewlyAddedProperty' property
as there's now a property in the wsdl that isn't in the class.
I've tried to work around it by using a magic getter and returning things like false
, null
etc but as they're not valid values according to the wsdl it still throws up a fatal error.
In an ideal world the client would just set that new property on the object even if there isn't a property defined on the class, is that possible? If not just suppressing the error would also be fine.
You can remove SoapClient
's class mapping and use another one, eg jsonmapper.
If your classes are annotated correctly, it's as simple as this example:
class noBisnodePersonClient extends SoapClient {
// ...
/**
* sokPerson
* @param noBisnodePersonSok $PersonSokReq
* @return noBisnodePersonSokResponse
*/
public function sokPerson(noBisnodePersonSok $PersonSokReq){
$return = $this->__soapCall(
'sokPerson',
array($PersonSokReq),
array('uri'=>'http://dbonline.no/webservices/wsdl/PersonInfo')
);
$mapper = new JsonMapper();
$object = $mapper->map($return, new noBisnodePersonSokResponse);
return $object;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With