问题
I'm calling a service witch among many other parameters demands an entry like (Taken from soapUI):
<v110:ReadWorkerRequest> <v111:Key v111:type="INITIALS">RKM</v111:Key> </v110:ReadWorkerRequest>
How do I get the Zend_Soap_Client to send the type-attribute in the Key element?
As this is just part of a rather big service, I've been creating classes to create the datastructure, like:
class Key {
public $_ = 'RKM;
public $type = 'INITIALS';
}
class Body {
public $ReadWorkerRequest;
public function __construct() {
$this->ReadWorkerRequest = new Key();
}
}
However, I do not even get to sending the request as PHP fails, telling me: "SOAP-ERROR: Encoding: object hasn't 'Key' property"
So my question is, how do I create an object structure, possibly with a subpart created as an Array which will honor this?
Or is the object structure correct, and I need to use classmap or SoapVar (I tried some combinations, but not with any success)
Happy holidays, for those of you who has them! :-)
回答1:
I have spent many hours myself trying to solve this problem but the best I could come up with was to use the XSD_ANYXML hack, eg:
$this->ReadWorkerRequest = new SoapVar( '<v111:Key v111:type="INITIALS">RKM</v111:Key>', XSD_ANYXML );
Its a pretty nasty hack though. Hopefully somebody else can provide a better solution.
来源:https://stackoverflow.com/questions/8577016/create-soap-request-with-element-attribute-using-zend-soap-client-and-stdobject