Create SOAP request with element attribute using Zend_Soap_Client and stdObject
Asked Answered
L

1

1

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! :-)

Lazarolazaruk answered 20/12, 2011 at 14:32 Comment(0)
H
0

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.

Ho answered 16/1, 2012 at 8:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.