Search code examples
magentoapache-axismagento-soap-api

SOAP Magento Error on Customer.Create


I am trying to create a customer from the Magja project and the AxisFault i am getting is a 100 "Customer email is required." . I am passing over the correct minimum required params from the 1.7 documentation. Long story my fault code is saying i am not including my email BUT it is clearly there (not putting the sensitive info on SO...so you just have to trust me :) ). Any Ideas?

Stack
org.eclipse.debug.core.DebugException: com.sun.jdi.ClassNotLoadedException: Type has not been loaded occurred while retrieving component type of array.

//soapclient line 208
result = sender.sendReceive(method)  -> method variable

<mag:call xmlns:mag="urn:Magento" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:SOAP-XML="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <sessionId>9be685563680f52c1ab5375bec545dfe</sessionId>
    <resourcePath>customer.create</resourcePath>
    <args SOAP-ENC:arrayType="xsd:ur-type[1]" xsi:type="SOAP-ENC:Array">
        <item SOAP-ENC:arrayType="xsd:ur-type[1]" xsi:type="SOAP-ENC:Array">
            <item xsi:type="SOAP-XML:Map">
                <item>
                    <key xsi:type="xsd:string">email</key>
                    <value xsi:type="xsd:string">MY EMAIL</value>
                </item>
                <item>
                    <key xsi:type="xsd:string">password_hash</key>
                    <value xsi:type="xsd:string">4cb9c8a8048fd02294477fcb1a41191a</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">store_id</key>
                    <value xsi:type="xsd:int">1</value>
                </item>
                <item>
                    <key xsi:type="xsd:string">lastname</key>
                    <value xsi:type="xsd:string">LName</value>
                </item>
                <item>
                    <key xsi:type="xsd:string">firstname</key>
                    <value xsi:type="xsd:string">Fname</value>
                </item>
                <item>
                    <key xsi:type="xsd:string">website_id</key>
                    <value xsi:type="xsd:int">1</value>
                </item>
            </item>
        </item>
    </args>
</mag:call>

//magentosoapclient line 215
throw axisFault (axisfault -> message)
<?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>100</faultcode>
            <faultstring>Customer email is required</faultstring>
        </SOAP-ENV:Fault>
    </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Solution

  • You'll need to trace/log the data on the Magento end of things. Somehow email's getting lost and/or munged in the process. The PHP code that's called for a customer creation is at

    #File: app/code/core/Mage/Customer/Model/Customer/Api.php
    public function create($customerData)
    {
        $customerData = $this->_prepareData($customerData);
        try {
            $customer = Mage::getModel('customer/customer')
                ->setData($customerData)
                ->save();
        } catch (Mage_Core_Exception $e) {
            $this->_fault('data_invalid', $e->getMessage());
        }
        return $customer->getId();
    }
    

    and the specific exception being sent back to your SOAP client is at

    #File: app/code/core/Mage/Customer/Model/Resource/Customer.php
    protected function _beforeSave(Varien_Object $customer)
    {
        parent::_beforeSave($customer);
    
        if (!$customer->getEmail()) {
            throw Mage::exception('Mage_Customer', Mage::helper('customer')->__('Customer email is required'));
        }
    

    There's something about your client call and/or the specific Magento system you're using that makes Magento think there's no customer email set. A few calls to Mage::Log should set you on the right path.