I already created custom api where I am able to pass array item (for example
$data = array('date'=>'2013-12-22','operation'=>'import','successful'=>'1', 'requeue'=>'0');)
but I would like to be able to pass multi dimensional array. Something like this:
$data = array(
0 => array('date'=>'2013-12-22','operation'=>'import','successful'=>'1', 'requeue'=>'0'),
1 => array('date'=>'2013-12-28','operation'=>'export','successful'=>'0', 'requeue'=>'1')
);
If I pass such an array I am getting only first record. How I should change my api getting the results I want?
this is how I am calling my api:
<?php
$host = "127.0.0.1/magento/index.php";
$client = new SoapClient("http://".$host. "/api/soap/?wsdl");
$apiuser= "test";
$apikey = "123";
$action = "sync.items";
$data = array(
0 => array('date'=>'2013-12-22','operation'=>'import','successful'=>'1', 'requeue'=>'0'),
1 => array('date'=>'2013-12-28','operation'=>'export','successful'=>'0', 'requeue'=>'1')
);
try {
$sessionId= $client->login($apiuser, $apikey);
$result = array();
$result= $client->call($sessionId, $action, $data);
var_dump($result);
}
catch (Exception $e){
echo var_dump($e);
throw $e;
}
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="syncreportsSyncItemsEntity">
<all>
<element name="date" type="xsd:date" minOccurs="1" />
<element name="operation" type="xsd:string" minOccurs="1" />
<element name="successful" type="xsd:int" minOccurs="1" />
<element name="requeue" type="xsd:int" minOccurs="1" />
</all>
</complexType>
<complexType name="syncreportsSyncItemsEntityArray">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="typens:syncreportsSyncListEntity[]" />
</restriction>
</complexContent>
</complexType>
<complexType name="syncreportsSyncCreateEntity">
<all>
<element name="date" type="xsd:date" minOccurs="1" />
<element name="operation" type="xsd:string" minOccurs="1" />
<element name="successful" type="xsd:int" minOccurs="1" />
<element name="requeue" type="xsd:int" minOccurs="1" />
</all>
</complexType>
</schema>
</types>
<message name="syncreportsSyncItemsRequest">
<part name="sessionId" type="xsd:string" />
<part name="data" type="typens:syncreportsSyncItemsEntity" />
</message>
<message name="syncreportsSyncItemsResponse">
<part name="result" type="typens:syncreportsSyncItemsEntityArray" />
</message>
<message name="syncreportsSyncCreateRequest">
<part name="sessionId" type="xsd:string" />
<part name="data" type="xsd:syncreportsSyncCreateEntity" />
</message>
<message name="syncreportsSyncCreateResponse">
<part name="result" type="typens:syncreportsSyncCreateEntityArray" />
</message>
<portType name="{{var wsdl.handler}}PortType">
<operation name="syncreportsSyncItems">
<documentation>Retrieve sync info</documentation>
<input message="typens:syncreportsSyncItemsRequest" />
<output message="typens:syncreportsSyncItemsResponse" />
</operation>
<operation name="syncreportsSyncCreate">
<documentation>Retrieve sync info</documentation>
<input message="typens:syncreportsSyncCreateRequest" />
<output message="typens:syncreportsSyncCreateResponse" />
</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="syncreportsSyncItems">
<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="syncreportsSyncCreate">
<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>
wsi.xml
<xsd:complexType name="syncreportsSyncCreateEntity">
<xsd:sequence>
<xsd:element name="date" type="xsd:date" />
<xsd:element name="operation" type="xsd:string" />
<xsd:element name="successful" type="xsd:int" />
<xsd:element name="requeue" type="xsd:int" />
</xsd:sequence>
</xsd:complexType>
<xsd:element name="syncreportsSyncCreateRequestParam">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
<xsd:element minOccurs="1" maxOccurs="1" name="data" type="typens:portfolioProjectAddEntity" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="syncreportsSyncCreateResponseParam">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="typens:portfolioProjectInfoEntityArray" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="syncreportsSyncItemsRequestParam">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="sessionId" type="xsd:string" />
<xsd:element minOccurs="1" maxOccurs="1" name="data" type="typens:portfolioProjectAddEntity" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="syncreportsSyncItemsResponseParam">
<xsd:complexType>
<xsd:sequence>
<xsd:element minOccurs="1" maxOccurs="1" name="result" type="typens:portfolioProjectInfoEntityArray" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="syncreportsSyncItemsRequest">
<wsdl:part name="parameters" element="typens:syncreportsSyncItemsRequestParam" />
</wsdl:message>
<wsdl:message name="syncreportsSyncItemsResponse">
<wsdl:part name="parameters" element="typens:syncreportsSyncItemsResponseParam" />
</wsdl:message>
<wsdl:message name="syncreportsSyncCreateRequest">
<wsdl:part name="parameters" element="typens:syncreportsSyncCreateRequestParam" />
</wsdl:message>
<wsdl:message name="syncreportsSyncItemsResponse">
<wsdl:part name="parameters" element="typens:syncreportsSyncCreateResponseParam" />
</wsdl:message>
<wsdl:portType name="{{var wsdl.handler}}PortType">
<wsdl:operation name="syncreportsSyncItems">
<wsdl:documentation>Retrieve project info</wsdl:documentation>
<wsdl:input message="typens:syncreportsSyncItemsRequest" />
<wsdl:output message="typens:syncreportsSyncItemsResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:portType name="{{var wsdl.handler}}PortType">
<wsdl:operation name="syncreportsSyncCreate">
<wsdl:documentation>Retrieve project info</wsdl:documentation>
<wsdl:input message="typens:syncreportsSyncCreateRequest" />
<wsdl:output message="typens:syncreportsSyncCreateResponse" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="{{var wsdl.handler}}Binding" type="typens:{{var wsdl.handler}}PortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="syncreportsSyncItems">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="syncreportsSyncCreate">
<soap:operation soapAction="" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="{{var wsdl.name}}Service">
<wsdl:port name="{{var wsdl.handler}}Port" binding="typens:{{var wsdl.handler}}Binding">
<soap:address location="{{var wsdl.url}}" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>