【问题标题】:Error in custom soap api call in magentomagento中自定义soap api调用错误
【发布时间】:2014-05-09 11:55:23
【问题描述】:

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

[faultstring] => 函数 ("customerCustomerUserlogin") 不是 此服务的有效方法 [故障代码] => 客户端 [故障代码] => 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>

我在上面添加了代码...有人可以帮我吗?

【问题讨论】:

  • @chandu_cp , 请提供一些代码。
  • @muk 我已经添加了代码..

标签: php web-services magento soap


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-10
    • 1970-01-01
    • 1970-01-01
    • 2011-11-23
    • 1970-01-01
    • 2016-12-01
    • 1970-01-01
    相关资源
    最近更新 更多