0

app/code/local/Envanto/customapimodule/etc/api.xml

<?xml version="1.0"?>
<config>
  <api>
    <resources>
      <customapimodule_product translate="title" module="customapimodule">
        <model>customapimodule/product_api</model>
        <title>Demo Custommoduleapi API</title>
        <acl>customapimodule/product</acl>
        <methods>
          <list translate="title" module="customapimodule">
            <title>List of products</title>
            <method>items</method>
          </list>
           <info translate="title" module="portfolio"><!-- project details -->
              <title>Retrieve product info</title>
              <acl>customapimodule/product/info</acl>
          </info>
        </methods>
      </customapimodule_product>
    </resources>
    <resources_alias>
      <product>customapimodule_product</product>
    </resources_alias>
    <v2>
      <resources_function_prefix>
         <product>customapimoduleProduct</product>
      </resources_function_prefix>
    </v2>
    <acl>
      <resources>
        <customapimodule translate="title" module="customapimodule">
          <title>Products</title>
          <sort_order>5</sort_order>
          <product translate="title" module="customapimodule">
            <title>Product data</title>
            <info translate="title" module="customapimodule">
              <title>Info</title>
            </info>
          </product>
        </customapimodule>
      </resources>
    </acl>
  </api>
</config>

app/code/local/Envanto/customapimodule/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/" />
      <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>
       <complexType name="customapimoduleProductListEntity"><!-- define type for project list -->
                <all>
                    <element name="entity_id" type="xsd:string" minOccurs="1" />
                    <element name="name" type="xsd:string" minOccurs="1" />
                    <element name="description" type="xsd:string" minOccurs="0" />
                    <element name="status" type="xsd:string" minOccurs="0" />
                    <element name="created_at" type="xsd:string" minOccurs="1" />
                    <element name="updated_at" type="xsd:string" minOccurs="1" />
                </all>
            </complexType>
            <complexType name="customapimoduleProductListEntityArray"><!-- define type array of projects -->
                <complexContent>
                    <restriction base="soapenc:Array">
                        <attribute ref="soapenc:arrayType" wsdl:arrayType="typens:customapimoduleProductListEntity[]" />
                    </restriction>
                </complexContent>
            </complexType>
          <complexType name="customapimoduleProductInfoEntity"><!-- define type for retrieve info -->
                <all>
                    <element name="entity_id" type="xsd:string" minOccurs="1" />
                    <element name="name" type="xsd:string" minOccurs="1" />
                    <element name="description" type="xsd:string" minOccurs="0" />
                    <element name="status" type="xsd:string" minOccurs="0" />
                    <element name="created_at" type="xsd:string" minOccurs="1" />
                    <element name="updated_at" type="xsd:string" minOccurs="1" />
                </all>
            </complexType>

    </schema>
  </types>
  <message name="customapimoduleProductListRequest">
    <part name="sessionId" type="xsd:string" />
  </message>
  <message name="customapimoduleProductListResponse">
    <part name="products" type="typens:fieldInfoArray" />
  </message>
     <message name="customapimoduleProductInfoRequest">
        <part name="sessionId" type="xsd:string" />
        <part name="productSku" type="xsd:string" />
    </message>
      <message name="customapimoduleProductInfoResponse">

        <part name="result" type="typens:fieldInfoArray" />
    </message>

  <portType name="{{var wsdl.handler}}PortType">
    <operation name="customapimoduleProductList">
      <documentation>List of products</documentation>
      <input message="typens:customapimoduleProductListRequest" />
      <output message="typens:customapimoduleProductListResponse" />
    </operation>
     <operation name="customapimoduleProductInfo">
            <documentation>Retrieve product info</documentation>
            <input message="typens:customapimoduleProductInfoRequest" />
            <output message="typens:customapimoduleProductInfoResponse" />
     </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="customapimoduleProductList">
      <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="customapimoduleProductInfo">
            <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>

My API Code is ini_set("soap.wsdl_cache_enabled", "0"); $client = new SoapClient('http://localhost/magento/pos/index.php/api/v2_soap/?wsdl', array('cache_wsdl' => WSDL_CACHE_NONE));

            $product = $observer->getEvent()->getProduct(); 

            $sessionid = $client->__call('login',array('XXX', 'XXXXX'));

            $productSku = $product->getSku();
            echo $productSku; 
            $result = $client->__call('customapimoduleProductInfo',array($sessionid,$productSku));

            $entity_id = 16750;

            $productDetail =   $client->catalogProductInfo($sessionid,$entity_id);

My problem is that now custom function called but in built function like "catalogProductInfo" not called give error Invalid API PATH.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.