SoapVar and Encoding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Everyone,

I'm having some trouble with encoding for SoapVars and I was wondering if someone could help me understand what's going on here (I'm working in non-WSDL mode). Basically, I need the following in the SOAP request body:

<ns6:create>
	...
	<property>
		<name>Property 1</name>
		<value>Test Value 1</value>
	</property>
	<property>
		<name>Property 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;
}

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

    public function __construct(...) {
         ...
         $property = array(
         	new NamedValue("Property 1", "Test Value 1"),
		new NamedValue("Property 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("update", $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>Property 1</name>
			<value>Test Value 1</value>
		</SOAP-ENC:Struct>
		<SOAP-ENC:Struct>
			<name>Property 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 Osman
http://www.eval.ca

--
PHP Soap Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Kernel Newbies]     [PHP Database]     [Yosemite]

  Powered by Linux