New: Add webservice to get all product ids.

This commit is contained in:
Laurent Destailleur 2012-03-16 23:06:38 +01:00
parent 81a97edf9c
commit 4806f2ad54

View File

@ -88,32 +88,32 @@ $server->wsdl->addComplexType(
'all',
'',
array(
'id' => array('name'=>'id','type'=>'xsd:string'),
'ref' => array('name'=>'ref','type'=>'xsd:string'),
'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
'type' => array('name'=>'type','type'=>'xsd:string'),
'label' => array('name'=>'label','type'=>'xsd:string'),
'description' => array('name'=>'description','type'=>'xsd:string'),
'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
'note' => array('name'=>'note','type'=>'xsd:string'),
'status_tobuy' => array('name'=>'status_tobuy','type'=>'xsd:string'),
'status_tosell' => array('name'=>'status_tosell','type'=>'xsd:string'),
'barcode' => array('name'=>'barcode','type'=>'xsd:string'),
'barcode_type' => array('name'=>'barcode_type','type'=>'xsd:string'),
'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
'customcode' => array('name'=>'customcode','type'=>'xsd:string'),
'id' => array('name'=>'id','type'=>'xsd:string'),
'ref' => array('name'=>'ref','type'=>'xsd:string'),
'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
'type' => array('name'=>'type','type'=>'xsd:string'),
'label' => array('name'=>'label','type'=>'xsd:string'),
'description' => array('name'=>'description','type'=>'xsd:string'),
'date_creation' => array('name'=>'date_creation','type'=>'xsd:dateTime'),
'date_modification' => array('name'=>'date_modification','type'=>'xsd:dateTime'),
'note' => array('name'=>'note','type'=>'xsd:string'),
'status_tobuy' => array('name'=>'status_tobuy','type'=>'xsd:string'),
'status_tosell' => array('name'=>'status_tosell','type'=>'xsd:string'),
'barcode' => array('name'=>'barcode','type'=>'xsd:string'),
'barcode_type' => array('name'=>'barcode_type','type'=>'xsd:string'),
'country_id' => array('name'=>'country_id','type'=>'xsd:string'),
'country_code' => array('name'=>'country_code','type'=>'xsd:string'),
'customcode' => array('name'=>'customcode','type'=>'xsd:string'),
'price_net' => array('name'=>'price_net','type'=>'xsd:string'),
'price' => array('name'=>'price','type'=>'xsd:string'),
'price_base_type' => array('name'=>'price_base_type','type'=>'xsd:string'),
'price_net' => array('name'=>'price_net','type'=>'xsd:string'),
'price' => array('name'=>'price','type'=>'xsd:string'),
'price_base_type' => array('name'=>'price_base_type','type'=>'xsd:string'),
'stock_alert' => array('name'=>'stock_alert','type'=>'xsd:string'),
'stock_real' => array('name'=>'stock_real','type'=>'xsd:string'),
'stock_pmp' => array('name'=>'stock_pmp','type'=>'xsd:string'),
'canvas' => array('name'=>'canvas','type'=>'xsd:string'),
'import_key' => array('name'=>'import_key','type'=>'xsd:string')
'stock_alert' => array('name'=>'stock_alert','type'=>'xsd:string'),
'stock_real' => array('name'=>'stock_real','type'=>'xsd:string'),
'stock_pmp' => array('name'=>'stock_pmp','type'=>'xsd:string'),
'canvas' => array('name'=>'canvas','type'=>'xsd:string'),
'import_key' => array('name'=>'import_key','type'=>'xsd:string')
)
);
@ -132,21 +132,36 @@ $server->wsdl->addComplexType(
)
);
// Define other specific objects
$server->wsdl->addComplexType(
'arrayproducts',
'complexType',
'struct',
'all',
'',
'ProductsArray',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(
'id' => array('name'=>'id','type'=>'xsd:string'),
'ref' => array('name'=>'ref','type'=>'xsd:string'),
'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'),
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:product[]')
),
'tns:product'
);
$server->wsdl->addComplexType(
'ProductsArray2',
'complexType',
'array',
'sequence',
'',
array(
'product' => array(
'name' => 'product',
'type' => 'tns:product',
'minOccurs' => '0',
'maxOccurs' => 'unbounded'
)
)
);
// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
// Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
// http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
@ -189,7 +204,7 @@ $server->register(
// Entry values
array('authentication'=>'tns:authentication','filterproduct'=>'tns:filterproduct'),
// Exit values
array('result'=>'tns:result','arrayproducts'=>'tns:arrayproducts'),
array('result'=>'tns:result','products'=>'tns:ProductsArray2'),
$ns,
$ns.'#getListOfProductsOrServices',
$styledoc,
@ -440,12 +455,12 @@ function getListOfProductsOrServices($authentication,$filterproduct)
if ($resql)
{
$num=$db->num_rows($resql);
$i=0;
while ($i < $num)
{
$obj=$db->fetch_object($resql);
$arrayproducts[$obj->rowid]=array('id'=>$obj->rowid,'ref'=>$obj->ref,'ref_ext'=>$obj->ref_ext);
$arrayproducts[]=array('id'=>$obj->rowid,'ref'=>$obj->ref,'ref_ext'=>$obj->ref_ext);
$i++;
}
}
@ -461,17 +476,17 @@ function getListOfProductsOrServices($authentication,$filterproduct)
{
$objectresp = array(
'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel),
'arrayproducts'=>$arrayproducts
'products'=>$arrayproducts
);
}
else
{
$objectresp = array(
'result'=>array('result_code' => 'OK', 'result_label' => ''),
'arrayproducts'=>$arrayproducts
'products'=>$arrayproducts
);
}
var_dump($objectresp);exit;
return $objectresp;
}