I need to create a SOAP request which looks like this:
<s:element name="GetOrders">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="Token" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="Context" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="StartDate" type="s:dateTime"/>
<s:element minOccurs="1" maxOccurs="1" name="EndDate" type="s:dateTime"/>
<s:element minOccurs="1" maxOccurs="1" name="IncludeFulfilledOrders" type="s:boolean"/>
<s:element minOccurs="0" maxOccurs="1" name="ProductNumber" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
I’ve created a class for the variables:
class GetOrders {
public $Token = "THE_TOKEN"; // string
public $Context='THE_CONTEXT'; // string
public $StartDate=""; // dateTime
public $EndDate=""; // dateTime
public $IncludeFulfilledOrders=true; // boolean
public $ProductNumber=""; // string
}
The function that runs the soap call looks like this:
public function GetOrders(GetOrders $parameters) {
return $this->__soapCall('GetOrders',array('parameters'=>array($parameters)), array(
'uri' => 'http://www.domain.net/',
'soapaction' => ''
)
);
}
I’m getting the error:
SoapFault exception: [Client] SOAP-ERROR: Encoding: object has no ‘StartDate’ property in…
Here is a var_dump of the $parameters I am passing:
object(GetOrders)#1 (6) {
["Token"]=>
string(17) "THE_TOKEN"
["Context"]=>
string(7) "THE_CONTEXT"
["StartDate"]=>
string(25) "2012-09-01T00:00:00-05:00"
["EndDate"]=>
string(25) "2012-09-30T00:00:00-05:00"
["IncludeFulfilledOrders"]=>
bool(true)
["ProductNumber"]=>
string(10) "P-PRODUCT"
}
I can’t seem to figure out what the issue with the StartDate is. I believe the format is correct. I don’t know much about SOAP though so I apologize if this is a newb question.
Thanks!
Turns out my function had an error in it that was throwing this.
This is how the function should have read.
Notice the array(‘parameters’=>$parameters) is different than above.
It’s always something little…