API SOAP v1 – Fix ‘Cannot Use Object of Type stdClass as Array’

apisoapwsdl

I am testing called by SoapUI 5.2.0 software creating xmls, and as I have extra options for my call customer.create using the SOAP V1 and the code:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Magento">    <soapenv:Header/>    <soapenv:Body>
      <urn:call>
         <sessionId>6df66fd6fd6fd6f6df6df6d6fd</sessionId>
         <resourcePath>customer.create</resourcePath>
         <args SOAP-ENC:arrayType="ns2:Map[1]" xsi:type="SOAP-ENC:Array">
            <item xsi:type="ns2:Map">
              <item>
              <key xsi:type="xsd:string">email</key>
              <value xsi:type="xsd:string">my_email@hotmail.com</value>
            </item>
            <item>
              <key xsi:type="xsd:string">firstname</key>
              <value xsi:type="xsd:string">Matheus</value>
            </item>
            <item>
              <key xsi:type="xsd:string">lastname</key>
              <value xsi:type="xsd:string">Silva</value>
            </item>
            <item>
              <key xsi:type="xsd:string">password</key>
              <value xsi:type="xsd:string">pass123456</value>
            </item>
            <item>
              <key xsi:type="xsd:string">website_id</key>
              <value xsi:type="xsd:int">1</value>
            </item>
            <item>
              <key xsi:type="xsd:string">store_id</key>
              <value xsi:type="xsd:int">1</value>
            </item>
            <item>
              <key xsi:type="xsd:string">group_id</key>
              <value xsi:type="xsd:int">1</value>
            </item>
            <item>
              <key xsi:type="xsd:string">dob</key>
              <value xsi:type="xsd:string">14081991</value>
            </item>
            <item>
              <key xsi:type="xsd:string">account[tipopessoa]</key>
              <value xsi:type="xsd:int">1</value>
            </item>
            <item>
              <key xsi:type="xsd:string">account[cpf]</key>
              <value xsi:type="xsd:string">23039210823</value>
            </item>
            <item>
              <key xsi:type="xsd:string">account[rg]</key>
              <value xsi:type="xsd:string">478251075</value>
            </item>
            <item>
              <key xsi:type="xsd:string">account[cnpj]</key>
              <value xsi:type="xsd:string">01234567000110</value>
            </item>
            <item>
              <key xsi:type="xsd:string">account[ie]</key>
              <value xsi:type="xsd:string">110042490114</value>
            </item>
            <item>
              <key xsi:type="xsd:string">account[razaosocial]</key>
              <value xsi:type="xsd:string">ItepNess Ltda</value>
            </item>                                      
            </item>
         </args>
      </urn:call>    </soapenv:Body> </soapenv:Envelope>

These new options such as <key xsi:type="xsd:string">account [rg]</key> created the module and am calling, however the results call me the error:

Cannot use object of type stdClass as array

<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>

How This error works and how can I fix? Thanks in advance

Best Answer

I solve changing the top header:

<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>
      <ns1:call>

And the end header:

         </args>
      </ns1:call>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>