Re: help with soapvar and xml list

[email protected]
Newsgroups php.soap
Message-ID <[email protected]>
> $params->SecurityToken = new SoapVar($sectoken, XSD_STRING, 'string',  
> "http://www.w3.org/2001/XMLSchema");
> $params->DepartureDateTime = new SoapVar('2007-06-06', XSD_STRING,  
> 'string', "http://www.w3.org/2001/XMLSchema");
> $params->DepAirportCode = new SoapVar('BOI', XSD_STRING, 'string',  
> "http://www.w3.org/2001/XMLSchema");
> $client = new SoapClient('file.wsdl');
> $airresult = $client->OFSByAirportPairPerHour($air);
> $airport = $airresult->OFSByAirportPairPerHourResult;
>

It all depends on if you REALLY need to use SoapVars.

Without SoapVars it is very simple:

  $params->CarrierCodeFilterList = new StdClass();
  $params->CarrierCodeFilterList->CarrierCode = array("string1", "string2");

If you have to use SoapVars (which is not always - in fact I found using  
SoapVars necessary only where ComplexType with extensions were used in  
WSDL - rare thing):

  $carrierCode1 = new SoapVar("string1", XSD_STRING, "string",  
"http://www.w3.org/2001/XMLSchema");
  $carrierCode2 = new SoapVar("string1", XSD_STRING, "string",  
"http://www.w3.org/2001/XMLSchema");

  $carrierCodeFilterList = new StdClass();
  $carrierCodeFilterList->CarrierCode = array($carrierCode1, $carrierCode2);

  $params->CarrierCodeFilterList = new SoapVar($carrierCodeFilterList,  
SOAP_ENC_OBJECT, "CarrierCodeFilterList",  "http://ws.oag.com");


The main trick is to use arrays where some element is defined with  
maxOccurs > 1 in WSDL.
(I guessed type name of CarrierCodeFilterList - it should be easily found  
in WSDL. I'm not sure what should be there if it is an anonymous type)

Hope it helps (I didn't test the code above).
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.