Search code examples
iosmagentomagento-soap-api

Whats correct way to use multicall method of magento SOAP API?


I have implemented two ways to call magento methods, first with http://sudzc.com/ classes and second with http://www.wsdl2code.com/Pages/Home.aspx classes. but not getting product info by either way.

Please check two pairs of request and response for multi call method :-

SUDZC

Request:-

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
  <multiCall>
     <sessionId>b543e92c12944a5512c624a4944423d8</sessionId>
     <calls>(
"catalog_product.info"
    )</calls>
     <options>(
     productId,
     5
    )</options>
  </multiCall>
</soap:Body>
</soap:Envelope>

Response:-

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns1="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
  <ns1:multiCallResponse>
     <multiCallReturn SOAP-ENC:arrayType="xsd:ur-type[0]" xsi:type="ns1:FixedArray" />
  </ns1:multiCallResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Wsdl2code (I think there is problem with soap envelope here, because no param specified inside , let me know how to correct it)

Request:-

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
  <multiCall xmlns="urn:Magento">
     <sessionId>b543e92c12944a5512c624a4944423d8</sessionId>
     <calls>
        <MagentoService>
           <SoapVersion>Default</SoapVersion>
           <AllowAutoRedirect>0</AllowAutoRedirect>
           <EnableDecompression>0</EnableDecompression>
           <UnsafeAuthenticatedConnectionSharing>0</UnsafeAuthenticatedConnectionSharing>
           <UseDefaultCredentials>0</UseDefaultCredentials>
           <PreAuthenticate>0</PreAuthenticate>
           <Url>http://mediaplus.co.za/api/soap/?wsdl/multiCall</Url>
           <Timeout>0</Timeout>
        </MagentoService>
     </calls>
  </multiCall>
 </soap:Body>
</soap:Envelope>

Response:-

<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Body>
  <SOAP-ENV:Fault>
     <faultcode>SOAP-ENV:Server</faultcode>
     <faultstring>Cannot use object of type stdClass as array</faultstring>
  </SOAP-ENV:Fault>
 </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Solution

  • After lots of googling I have managed to solve this problem by looking at this post. It has an example project in it.