Question

I am developing a custom api using soap call in magento to login customer from mobile app to magento and then redirect back to mobile app.I have created the customer using the default soap calls in magento but there is no soap function for login the customers.i have created the custome api similar to the default customer creation method but am getting the below error.

[faultstring] => Function ("customerCustomerUserlogin") is not a valid method for this service [faultcode] => Client [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/

The code below is am using

$soapclient = new SoapClient('http://localhost/magento/api/v2_soap/?wsdl');
            //$soapclient = new SoapClient('http://localhost/magento/api/soap/?wsdl',$opt);

            $session = $soapclient->login('soapapi','devmage123');

            $customerId = $soapclient->customerCustomerUserlogin($session, $loginDetails);

Here is the code i have used :

in customer/etc/api.xml

<config>
    <api>
        <resources>
            <customer translate="title" module="customer">
                <model>customer/customer_api</model>
                <title>Customer API</title>
                <acl>customer</acl>
                <methods>
                    <userlogin translate="title" module="customer">
                        <title>Userlogin customer</title>
                        <acl>customer/userlogin</acl>
                    </userlogin>
                </methods>
                <faults module="customer">
                    <login_invalid>
                        <code>110</code>
                        <message>Invalid Username and Password.</message>
                    </login_invalid>
                </faults>
            </customer>
          </resources>
        <acl>
        <resources>
            <customer translate="title" module="customer">
               <userlogin translate="title" module="customer">
                    <title>Userlogin</title>
               </userlogin>
            </customer>
         </resources>
       </acl>
    </api>
 </config>

in customer/etc/wsdl.xml

 <?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns:typens="urn:{{var wsdl.name}}" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://schemas.xmlsoap.org/wsdl/"
    name="{{var wsdl.name}}" targetNamespace="urn:{{var wsdl.name}}">
    <types>
        <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:Magento">
            <import namespace="http://schemas.xmlsoap.org/soap/encoding/" schemaLocation="http://schemas.xmlsoap.org/soap/encoding/" />               

        </schema>
    </types>

    <message name="customerCustomerUserloginRequest">
        <part name="sessionId" type="xsd:string" />
        <part name="loginDetails" type="typens:ArrayOfString" />
    </message>
    <message name="customerCustomerUserloginResponse">
        <part name="result" type="xsd:int"/>
    </message>

    <portType name="{{var wsdl.handler}}PortType">
        <operation name="customerCustomerUserlogin">
            <documentation>Retrieve customer data</documentation>
            <input message="typens:customerCustomerUserloginRequest" />
            <output message="typens:customerCustomerUserloginResponse" />
        </operation>            
    </portType>
    <binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http" />

        <operation name="customerCustomerUserlogin">
            <soap:operation soapAction="urn:{{var wsdl.handler}}Action" />
            <input>
                <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
            </input>
            <output>
                <soap:body namespace="urn:{{var wsdl.name}}" use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" />
            </output>
        </operation>         

    </binding>
</definitions>

I Have added code above...could any one help me?

Was it helpful?

Solution

After in api.xml try adding the following:

   <v2>
        <resources_function_prefix>
            <customerCustomer>customerCustomer</customerCustomer>
        </resources_function_prefix>
    </v2>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top