Đường dẫn api không hợp lệ


8

Xin chào Tôi đã tạo api tùy chỉnh để đăng nhập người dùng, nó hoạt động tốt. Nhưng tôi đã cố gắng tạo api để có được hình ảnh thể loại. nó đưa ra đường dẫn api không hợp lệ cho api magento được xây dựng. Dưới đây là các tập tin cấu hình tôi đang sử dụng.

Cấu hình

    <?xml version="1.0"?>
<config>
  <modules>
    <Mycustom_Masterapi>
      <version>1.0</version>
    </Mycustom_Masterapi>
  </modules>
  <global>
    <models>
      <masterapi>
        <class>Mycustom_Masterapi_Model</class>
      </masterapi>
    </models>
    <helpers>
      <masterapi>
        <class>Mycustom_Masterapi_Helper</class>
      </masterapi>
    </helpers>
  </global>
</config>

api.xml

<?xml version="1.0"?>
<config>
  <api>

    <resources>

      <masterapi_loginmodel translate="title" module="masterapi">
        <model>masterapi/loginmodel_api</model>
        <title>Demo Custommoduleapi API</title>
        <acl>masterapi/loginmodel</acl>
        <methods>
         <!-- <list translate="title" module="masterapi">
            <title>List of masterapi</title>
            <method>clogin</method>
          </list> -->
          <customerlogin translate="title" module="masterapi">
           <title>List of masterapi</title>
          </customerlogin>

        </methods>
      </masterapi_loginmodel>

       <masterapi_category translate="title" module="masterapi">
        <model>masterapi/category_api</model>
        <title>Demo category API</title>
        <acl>masterapi/category</acl>
        <methods>
         <!-- <list translate="title" module="masterapi">
            <title>List of masterapi</title>
            <method>clogin</method>
          </list> -->
          <getID translate="title" module="masterapi">
           <title>List of category</title>
          </getID>

        </methods>
      </masterapi_category>


    </resources>


    <resources_alias>
      <loginmodel>masterapi_loginmodel</loginmodel>
      <category>masterapi_category</category>
    </resources_alias>

    <v2>
      <resources_function_prefix>
         <loginmodel>masterapiLoginmodel</loginmodel>
          <category>masterapiCategory</category>
      </resources_function_prefix>
    </v2>

    <acl>
      <resources>
        <masterapi translate="title" module="masterapi">
          <title>Loginmodel</title>
          <sort_order>5</sort_order>
          <loginmodel translate="title" module="masterapi">
            <title>loginmodel data</title>
          </loginmodel>

           <category translate="title" module="masterapi">
            <title>loginmodel data</title>
          </category>

        </masterapi>

      </resources>
    </acl>
  </api>
</config>

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/" />
      <complexType name="fieldInfo">
        <sequence>
          <element name="entity_id" type="xsd:string"/>
          <element name="name" type="xsd:string"/>
        </sequence>
      </complexType>
      <complexType name="fieldInfoArray">
        <complexContent>
          <restriction base="soapenc:Array">
            <attribute ref="soapenc:arrayType" wsdl:arrayType="typens:fieldInfo[]" />
          </restriction>
        </complexContent>
      </complexType>


      <!---Declare our types-->
            <complexType name="catalogCategoryID">
                <sequence>
                    <element name="category_id" type="xsd:string" />
                    <element name="category_name" type="xsd:string" />
                </sequence>
            </complexType>
       <!---Declare our input and output parameters-->
            <element name="catalogCategoryGetIDRequestParam">
                <complexType>
                    <sequence>
                        <element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
                        <element minOccurs="1" maxOccurs="1" name="category_name" type="xsd:string" />
                    </sequence>
                </complexType>
            </element>
            <element name="catalogCategoryGetIDResponseParam">
                <complexType>
                    <sequence>
            <!---here we use the type we declared earlier as our output parameter-->
                        <element minOccurs="1" maxOccurs="1" name="result" type="typens:catalogCategoryID" />
                    </sequence>
                </complexType>
            </element>
            <!---Boohoo-->


    </schema>
  </types>

  <message name="masterapiLoginmodelListRequest">
    <part name="sessionId" type="xsd:string" />
    <part name="user" type="xsd:string" />
     <part name="pass" type="xsd:string" /> 
  </message>

  <message name="masterapiLoginmodelListResponse">
    <part name="customlogin" type="xsd:string" />
  </message>



  <portType name="{{var wsdl.handler}}PortType">
    <operation name="masterapiLoginmodelCustomerlogin">
      <documentation>List of masterapi</documentation>
      <input message="typens:masterapiLoginmodelListRequest" />
      <output message="typens:masterapiLoginmodelListResponse" />
    </operation>

    <operation name="masterapiCategoryGetID">
      <documentation>List of masterapi</documentation>
      <input message="typens:masterapiCategoryCustomerloginRequest" />
      <output message="typens:catalogCategoryGetIDResponse" />
    </operation>

  </portType>


   <message name="masterapiCategoryCustomerloginRequest">
    <part name="sessionId" type="xsd:string" />
    <part name="category_name" type="xsd:string" />

  </message>

   <message name="catalogCategoryGetIDResponse">
        <part name="parameters" type="xsd:string" />
    </message>


  <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="masterapiLoginmodelCustomerlogin">
      <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>

     <operation name="masterapiCategoryGetID">
      <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>



  <service name="{{var wsdl.name}}Service">
    <port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
      <soap:address location="{{var wsdl.url}}" />
    </port>
  </service>
</definitions>

tập tin php của tôi: Api.php

<?php
// app/code/local/Envato/Customlogin/Model/Loginmodel/Api.php
class Mycustom_Masterapi_Model_Category_Api extends Mage_Api_Model_Resource_Abstract
{
  /**
 * retrieves Category ID based on category name
 *
 */
 public function getID($category_name){

 $category_model = Mage::getModel('catalog/category')->loadByAttribute('name',$category_name);
 $result = array();
 $result['category_id'] = $category_model->getId();
 $result['category_name'] = $category_name;

 return $category_name;
 }
}

Tôi theo liên kết này liên kết này . Tôi đã thực hiện các thay đổi cho nhật ký người dùng trong hoạt động tuyệt vời của nó. Nhưng tôi muốn api tùy chỉnh để có được Hình ảnh Danh mục dọc theo cây danh mục. Nhưng khi tôi gọi "catalogC CategoryTree" bằng cách sử dụng xà phòng thì nó là "Đường dẫn Api không hợp lệ". Xin vui lòng cho tôi biết những gì sai lầm trong các tập tin cấu hình.

Câu trả lời:


0

Bạn có thể thử thay đổi api.xml của mình thành một cái gì đó tương tự như sau:

<?xml version="1.0"?>
<config>
    <api>
        <resources>
            <companygroupfacebookconnector translate="title" module="companygroup_facebookconnector">
                <model>CompanyGroup_FacebookConnector_Model_Api</model>
                <title>Product Resource</title>
                <acl>companygroupfacebookconnector</acl>
                <methods>
                    <productinfo translate="title" module="companygroup_facebookconnector">
                        <title>Retrieve Product Data</title>
                        <acl>companygroupfacebookconnector/product</acl>
                        <method>productInfo</method>
                    </productinfo>
                </methods>
                <faults module="companygroup_facebookconnector">
                    <data_invalid>
                        <code>100</code>
                        <message>Param is invalid.</message>
                    </data_invalid>
                    <not_exists>
                        <code>101</code>
                        <message>Item doesn't exist.</message>
                    </not_exists>
                </faults>
            </companygroupfacebookconnector>

            <companyfbcustomer translate="title" module="companygroup_facebookconnector">
                <model>CompanyGroup_FacebookConnector_Model_Api_Customer_Api</model>
                <title>Product Resource</title>
                <acl>companygroupfacebookconnector</acl>
                <methods>
                    <connectcustomer translate="title" module="companygroup_facebookconnector">
                        <title>Connect customer with Messenger</title>
                        <acl>companygroupfacebookconnector/customer</acl>
                        <method>connectCustomer</method>
                    </connectcustomer>
                </methods>
                <faults module="companygroup_facebookconnector">
                    <data_invalid>
                        <code>100</code>
                        <message>Param is invalid.</message>
                    </data_invalid>
                    <not_exists>
                        <code>101</code>
                        <message>Item doesn't exist.</message>
                    </not_exists>
                    <is_connected>
                        <code>102</code>
                        <message>Customer is connected.</message>
                    </is_connected>
                    <unexpected>
                        <code>105</code>
                        <message>Unexpected Error.</message>
                    </unexpected>
                </faults>
            </companyfbcustomer>
        </resources>

        <v2>
            <resources_function_prefix>
                <companygroupfacebookconnector>companygroupfacebookconnectorProduct</companygroupfacebookconnector>
               <companyfbcustomer>companyfbcustomerCustomer</companyfbcustomer>
            </resources_function_prefix>
        </v2>
        <acl>
            <resources>
                <companygroupfacebookconnector translate="title" module="companygroup_facebookconnector">
                    <title>FbBot Api</title>
                    <sort_order>1</sort_order>
                    <product translate="title" module="companygroup_facebookconnector">
                        <title>Product Data</title>
                    </product>

                    <customer translate="title" module="companygroup_facebookconnector">
                        <title>Customer Info</title>
                    </customer>
                </companygroupfacebookconnector>
            </resources>
        </acl>
    </api>
</config>

Bây giờ bạn có thể sử dụng companygroupfacebookconnector.productinfođể chạy phương thức.

class CompanyGroup_FacebookConnector_Model_Api extends Mage_Api_Model_Resource_Abstract
{

    public function productInfo($product_code)
    {
        Your code here
    }
}

hoặc companyfbcustomer.connectcustomerđến:

class CompanyGroup_FacebookConnector_Model_Api_Customer_Api extends Mage_Api_Model_Resource_Abstract
{

    public function connectCustomer($customerId)
    {
          Your code here
    }
}
Khi sử dụng trang web của chúng tôi, bạn xác nhận rằng bạn đã đọc và hiểu Chính sách cookieChính sách bảo mật của chúng tôi.
Licensed under cc by-sa 3.0 with attribution required.