magento中自定义soap api调用出错

时间:2014-05-09 11:55:23

标签: php web-services magento soap

我正在使用magento中的soap调用来开发一个自定义api,以便将客户从移动应用程序登录到magento,然后重定向回移动应用程序。我使用magento中的默认soap调用创建了客户,但是没有用于登录的soap功能customers.i已经创建了类似于默认客户创建方法的custome api,但是我得到了以下错误。

  

[faultstring] =>功能(" customerCustomerUserlogin")不是   此服务的有效方法   [faultcode] =>客户   [faultcodens] => http://schemas.xmlsoap.org/soap/envelope/

以下代码正在使用

$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);

以下是我使用的代码:

客户/ 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>
客户/ 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>

我在上面添加了代码......任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

在api.xml中尝试添加以下内容:

   <v2>
        <resources_function_prefix>
            <customerCustomer>customerCustomer</customerCustomer>
        </resources_function_prefix>
    </v2>