Reputation: 346260
I want to call a webservice using Zend_Soap_Client. This is the relevant code:
$params = new stdClass();
$params->transactionId = $transactionId;
$params->transactionState = $transactionState;
$params->details = $transactionDetails;
var_dump($params->details);
try {
$this->_soapClient->updateTransaction($params);
}
The problem is with the details
parameter, which is a complex type in the WSDL. $transactionDetails
contains an array with the (non-empty) elements of the complex type, and this is visible in the var_dump()
. Previously, I tried using a PHP class with the elements as properties. In both cases, what the SOAP client actually sends is this:
<SOAP-ENV:Body>
<ns1:UpdateTransactionRequest>
<transactionId>45</transactionId>
<transactionState>SUCCESS</transactionState>
<details/>
</ns1:UpdateTransactionRequest>
</SOAP-ENV:Body>
What am I doing wrong?
UPDATE: I think the cause of the problem is that the complexType declared for the parmeter is a base type, of which several extension types exist in the WSDL, and I want to use one of those extension types. I guess Zend_Soap_Client does not recognize any elements that are not present in the base type, which is all of them. Is there a way around this?
Upvotes: 3
Views: 1796
Reputation: 346260
The solution lies in the standard PHP SOAP client, which Zend_Soap_Client extends. The SoapVar
class allows you to wrap a parameter and specify the actual type to use. What I had to do is go back to using a PHP class for $transactionDetails
and this code:
$params->details = new SoapVar($transactionDetails,
SOAP_ENC_OBJECT, get_class($transactionDetails), $namespace);
Upvotes: 1