SOAP-ERROR: Encoding: Violation of encoding rules?

If you upgrade your PHP version to 7.3 or later, the previous WSDL cache may stop working.

The default install directory is /tmp and disabling cache or deleting the wsdl* cache files should remove the problem. I would recommend clearing the cache, or else your server will pull the WSDL every time (which may not be desirable).


I had the same problem.

In soapUI preferences I checked the option Preferences → Editor Settings → Validate Responses and I received this information:

line 3027: Invalid decimal value: unexpected char '44'.

This solved my problem. Field contained wrong type value.


It looks like you have a type mismatch somewhere, either while assembling your request (one of the parameters is not of type string), or the server returns something other than an int (violating the WSDL response definition and thus causing the client to consider the response invalid, as it expects something else).

  • To test the first case, ensure casting all parameters to string first
  • To test the second case, create your SoapClient with the trace option set to true in order to gain access to the actual XML answer from the server via $client->__getLastResponse() afterwards (You can use this for request debugging also via __getLastRequest()).

Some additional observations/questions:

  • According to the posted WSDL, the 'CanLoadProductRequest' has a fifth param 'esn', which you do not supply in your function call.
  • Any reason why you use $client->__soapCall("CanLoadProduct", $params) instead of $client->CanLoadProduct($username, $password, etc.)? (The first version is a lower level variation which is intended to be used for non_WSDL scenarios. The second version might give you a more detailed error/exception)
  • Can you test the SOAP Call to CanLoadProductRequest by some other means? The error could be on the server side, trying to return a result type that does not fit the WSDL definition.

Tags:

Php

Xml

Soap