updated below
Does anybody have an example of proper XML for the Magento SOAP v1 API to do something along the lines of the following?
client.call(session_token,'sales_order.list', {'filters':{'order_id':{'eq':12}}})
This is an example of the python suds call that is not working for me. Really, any example XML that filters sales_order.list, catalog_product.list, or customer.list would do. I have it working for the XMLRPC version already, but with python's SUDS and the SOAP v1 API, no matter what the filter, I get the entire list unfiltered as response. Here's what the XML currently looks like:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="urn:Magento" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns4:call>
<sessionId xsi:type="ns2:string">6634e1bd1004557677222fd81e809884</sessionId>
<resourcePath xsi:type="ns2:string">sales_order.list</resourcePath>
<args xsi:type="ns0:args">
<filters xsi:type="ns2:filters">
<order_id xsi:type="ns2:order_id">
<eq xsi:type="ns2:string">7</eq>
</order_id>
</filters>
</args>
</ns4:call>
</ns1:Body>
Of course I've already tried a million other variations on the above. I'm just wondering if my calls are correct and I've got a bad schema, or if the soap server's wonky, or what. Thus, if anyone has some proven correct XML to try to emulate, it'd help a lot.
Thanks!
update:
as per the first answer I've received so far, I've actually tried that format for filters already. The documentation for the Magento API is, as we know, varied, conflicting, and incomplete. here's the XML:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:ns3="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns2="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns4="urn:Magento" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header/>
<ns1:Body>
<ns4:call>
<sessionId xsi:type="ns2:string">93c7aaab38adaab5db732b211e5b</sessionId>
<resourcePath xsi:type="ns2:string">sales_order.list</resourcePath>
<args xsi:type="ns0:args">
<filter xsi:type="ns2:filter">
<value xsi:type="ns2:string">123</value>
<key xsi:type="ns2:string">order_id</key>
</filter>
</args>
</ns4:call>
</ns1:Body>
</SOAP-ENV:Envelope>
or possibly:
<ns1:Body>
<ns4:call>
<sessionId xsi:type="ns2:string">93c74cb7ef0baaaaab5db732b211e5b</sessionId>
<resourcePath xsi:type="ns2:string">sales_order.list</resourcePath>
<args xsi:type="ns0:args">
<filter xsi:type="ns2:filter">
<value xsi:type="ns2:value">
<value xsi:type="ns2:string">123</value>
<key xsi:type="ns2:string">eq</key>
</value>
<key xsi:type="ns2:string">order_id</key>
</filter>
</args>
</ns4:call>
</ns1:Body>
</SOAP-ENV:Envelope>
which looks like this:
{'filter':[{'key':'order_id','value':{'key':'eq','value':'123'}}]}
in python.
And those still return all orders (eventually...). So, as I mentioned, if anybody can actually give me some XML to emulate, it might be more useful. I'm likely going to root through the Magento source tomorrow and solve my own problem.
Well, I had to brush off (and learn) my PHP, but I have the answer here if any other poor saps come along and want to use SUDS (or python in general) with Magento.
this xml:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><ns1:call><sessionId xsi:type="xsd:string">bc11488aaae84c841ac237ea7f24ef</sessionId>
<resourcePath xsi:type="xsd:string">sales_order.list</resourcePath>
<args SOAP-ENC:arrayType="ns2:Map[1]" xsi:type="SOAP-ENC:Array">
<item xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">order_id</key>
<value xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">from</key>
<value xsi:type="xsd:string">11</value>
</item>
<item>
<key xsi:type="xsd:string">to</key>
<value xsi:type="xsd:string">12</value>
</item>
</value>
</item>
</item>
</args>
</ns1:call>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
is created by this php:
#! /usr/bin/php5
<?php
$client = new SoapClient('http://ip.ip.ip.ip/magento/index.php/api/?wsdl', array('trace'=>TRUE));
$session = $client->login('username', 'password');
$params = array(array(
'order_id' =>
array(
'from' => '10',
'to' => '12')));
$result = $client->call($session, 'sales_order.list', $params);
$resultXML = $client->__getLastRequest();
print($resultXML);
?>
Of course, it turns out that there are also sorts of SOAP-related encoding issues around Magento's particular implementation of the protocol - it seems as tho it's designed to work with the PHP Soap client, but not really with anything else. But this XML dump did allow me to hack around and get the SUDS connection off the ground - send me a message if you're curious. Oh, and a hat tip to @alanstorm.