SoapVar and Encoding

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Paul

    SoapVar and Encoding

    Hi Everyone,

    I've tried posting this question to the php-soap group, but got no
    replies so I was wondering if anyone here could help me understand
    what's going on with the following (I'm working in non-WSDL mode).
    Basically, I need the following in the SOAP request body:

    <ns6:create>
    ...
    <property>
    <name>Propert y 1</name>
    <value>Test Value 1</value>
    </property>
    <property>
    <name>Propert y 2</name>
    <value>Test Value 2</value>
    </property>
    </ns6:create>

    So I've created a class called Create that has the required members,
    and stores the property elements (which are instances of a class called
    NamedValue) in an array:

    class NamedValue {
    public $name;
    public $value;

    public function __construct($na me, $value) { ... }
    }

    class Create {
    public $id;
    public $parent;
    public $type;
    public $property;

    public function __construct(... ) {
    ...
    $property = array(
    new NamedValue("Pro perty 1", "Test Value 1"),
    new NamedValue("Pro perty 2", "Test Value 2")
    );
    }
    }

    and when calling the SOAP method:

    $client = new SoapClient(null , array(
    "location" => ...,
    "uri" => ...,
    "use" => SOAP_LITERAL
    ));
    $create = new Create(...);
    $queryParams = array(
    new SoapParam(new SoapVar($create , SOAP_ENC_OBJECT ), "statements "),
    );
    $response = $client->__soapCall("up date", $queryParams);

    However, instead of the XML I pasted in above, I'm getting each
    NamedValue instance wrapped in <Struct /> elements:

    <ns6:create>
    ...
    <property>
    <SOAP-ENC:Struct>
    <name>Propert y 1</name>
    <value>Test Value 1</value>
    </SOAP-ENC:Struct>
    <SOAP-ENC:Struct>
    <name>Propert y 2</name>
    <value>Test Value 2</value>
    </SOAP-ENC:Struct>
    </property>
    </ns6:create>

    Which is creating problems with the service I'm calling. Is there any
    way to control / avoid this? Any help or further information would be
    very much appreciated.

    Cheers,

    Paul

Working...