Search code examples
magentosoapwsdlmagento-soap-api

Magento soap error


I'm developing an iOS app that should integrate Magento e-commerce. Actually I'm trying to put objects into the cart, when I try to do that my app sends to server this WSDL:

<?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:ns2="http://xml.apache.org/xml-soap" 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>
      <call>
         <sessionId xsi:type="xsd:string">e976c086bf862d23fcc98e59fb23b499</sessionId>
         <resourcePath xsi:type="xsd:string">cart_product.add</resourcePath>
         <args xsi:type="SOAP-ENC:Array">
            <item xsi:type="ns2:Map">
               <item>
                  <key xsi:type="xsd:string">quoteId</key>
                  <value xsi:type="xsd:int">85</value>
               </item>
               <item>
                  <key xsi:type="xsd:string">products</key>
                  <value xsi:type="SOAP-ENC:Array">
                     <item xsi:type="ns2:Map">
                        <item>
                           <key xsi:type="xsd:string">product_id</key>
                           <value xsi:type="xsd:string">1</value>
                        </item>
                        <item>
                           <key xsi:type="xsd:string">qty</key>
                           <value xsi:type="xsd:int">1</value>
                        </item>
                     </item>
                  </value>
               </item>
            </item>
         </args>
      </call>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I tried it with this extension for Google Chrome, when I try to run the WSDL

<?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>1</faultcode>
            <faultstring>SQLSTATE[21000]: Cardinality violation: 1241 Operand should contain 1 column(s)</faultstring>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

What's wrong in my request? Can anyone help me?


Solution

  • Solved now I'm sending this:

    <?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:ns2="http://xml.apache.org/xml-soap" 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>
          <call>
             <sessionId xsi:type="xsd:string">38fd5af2c7fcfd55884b73ffded29225</sessionId>
             <resourcePath xsi:type="xsd:string">cart_product.add</resourcePath>
             <args xsi:type="SOAP-ENC:Array">
                <item xsi:type="xsd:int">142</item>
                <item xsi:type="SOAP-ENC:Array">
                   <item xsi:type="ns2:Map">
                      <item>
                         <key xsi:type="xsd:string">product_id</key>
                         <value xsi:type="xsd:string">2</value>
                      </item>
                      <item>
                         <key xsi:type="xsd:string">qty</key>
                         <value xsi:type="xsd:int">1</value>
                      </item>
                   </item>
                </item>
             </args>
          </call>
       </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    I was formatting wrong the request, indeed, if you compare the 2 request you will see the difference: I was sending the key "quoteId", but it's not necessary.