tags:

views:

147

answers:

2

OK, so I have this external SOAP based webservice, and PHP SoapClient. Everything is fine with basic requests, but I need to create a parameter set that looks like this:

<DatasetList>
  <DatasetID>K0001</DatasetID>
  <DatasetID>K0002</DatasetID>
</DatasetList>

For a single nested DatasetID tag I'd do:

$req = array( "DatasetList" => array( "DatasetId" => "K0001" ));
$client->getWebserviceCall($req);

but I need multiple DatasetID tags... I've tried assigning DatasetID as an array, but I just get:

<DatasetList>
  <DatasetID>Array</DatasetID>
</DatasetList>

Anyone help?

+1  A: 

Did you try the array this way?

$req = array( "DatasetList" => array("DatasetID" => array("K0001", "K0002));

Arthur Frankel
Yes, I just get <DatasetID>Array</DatasetID> out (literally)
PaulDarius
are you sure you had "DatasetID" correctly with the right case - i.e., in your post you have it with a lowercase 'i'.
Arthur Frankel
I meant lowercase 'd' - "DatasetId" => "K0001"
Arthur Frankel
Alas my case was correct... I just triple checked. The above is pseudo code, the real stuff is more complex
PaulDarius
can you provide a bit more code? When you try it with just K0001 does it work?
Arthur Frankel
Yes, it works fine with array("DatasetID" => "K0001") but not array(DatasetID => array("K0001"))
PaulDarius
A: 

You can do this only by wrote the Part with the identical tags by hand. But, the rest of values can you define in a array:

// Define multiple identical Tags for a part of the Array
$soap_var= new SoapVar('
  <DatasetID>1</DatasetID>
  <DatasetID>2</DatasetID>
';

// Define the other Values in the normal Way as an array
$req = array( 
  "DatasetList" => $soap_var,
  'value2'=>array('other'=>'values'
);