I am trying to make a SOAP call using PHP5. Here is the working schema:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:cat="http://com.xxx.xxxx/management/catalog"> <soapenv:Header/> <soapenv:Body> <cat:ManageCustomProducts siteId="0"> <!--You have a CHOICE of the next 2 items at this level--> <!--0 to 25 repetitions:--> <cat:task id="?"> <cat:insertCustomProduct manufacturerId="?" manufacturerPartNo="?" categoryId="?" categoryType="default"> <cat:skus> <!--Zero or more repetitions:--> <cat:sku type="?" number="?"/> </cat:skus> <cat:resources> <!--Zero or more repetitions:--> <cat:resource type="?" status="?" url="?"/> </cat:resources> <cat:locales> <!--1 or more repetitions:--> <cat:locale language="?" country="?"> <cat:descriptions> <!--Zero or more repetitions:--> <cat:description type="?">e gero</cat:description> </cat:descriptions> <cat:marketingDescription>cum sonoras</cat:marketingDescription> </cat:locale> </cat:locales> </cat:insertCustomProduct> </cat:task> </cat:ManageCustomProducts>
Here is my code to generate the SOAP XML...
$params=array(array( 'siteId' => '0', 'task' => array('id' => '1', 'insertCustomProduct' => array('manufacturerId' => '10000', 'manufacturerPartNo' => 'abc123', 'categoryId' => '20000', 'categoryType' => 'default', 'skus' => array('sku' => array('type' => 'MANUFACTURPARTNO', 'number' => 'abc123')), 'resources' => array('resource' => array('type' => '500', 'status' => 'Published', 'url' => 'http://content.xxx.com/img.jpg')), 'locales' => array('locale' => array('language' => 'en', 'country' => 'US', 'descriptions' => array('description' => array('_' =>'egeros', 'type' => '1')), 'marketingDescription' => array('_' => 'cum sonoras') ) ) ) ) ) ); $result = $client->__soapCall("ManageCustomProducts",$params); Here is the result...
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://com.xxx.xxx/management/catalog"> <SOAP-ENV:Body> <ns1:ManageCustomProducts siteId="0"> <ns1:task id="1"> <ns1:insertCustomProduct manufacturerId="10000" manufacturerPartNo="abc123" categoryId="20000" categoryType="default"> <ns1:skus> <ns1:sku type="MANUFACTURPARTNO" number="abc123"/> </ns1:skus> <ns1:resources> <ns1:resource type="500" status="Published" url="http://content.xxx.com/img.jpg"/> </ns1:resources> <ns1:locales> <ns1:locale language="en" country="US"> <ns1:descriptions> <ns1:description type="1"/> </ns1:descriptions> <ns1:marketingDescription/> </ns1:locale> </ns1:locales> </ns1:insertCustomProduct> </ns1:task> </ns1:ManageCustomProducts>
Even though I am using the suggested format of:
https://stackoverflow.com/a/1419407/3280665
array("foo" => array("_" => "cheese", "bar"=>"moo"));
This should produce following XML
<foo bar="moo">cheese</foo>` It is not adding the element value for description or marketingDescription. What am I doing wrong?
Thanks!
Update: I can now add the nodes, but how do I add the Type attribute to the description node?
$desc=array(); $desc[]=new SoapVar("This is description 1",XSD_STRING,null,null,'ns1:description'); $desc[]=new SoapVar("This is description 2",XSD_STRING,null,null,'ns1:description'); $description = new SoapVar($desc, SOAP_ENC_OBJECT, null,null,'description');'