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

@ -132,21 +132,36 @@ $server->wsdl->addComplexType(
) )
); );
// Define other specific objects
$server->wsdl->addComplexType( $server->wsdl->addComplexType(
'arrayproducts', 'ProductsArray',
'complexType', 'complexType',
'struct', 'array',
'all', '',
'SOAP-ENC:Array',
array(),
array(
array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:product[]')
),
'tns:product'
);
$server->wsdl->addComplexType(
'ProductsArray2',
'complexType',
'array',
'sequence',
'', '',
array( array(
'id' => array('name'=>'id','type'=>'xsd:string'), 'product' => array(
'ref' => array('name'=>'ref','type'=>'xsd:string'), 'name' => 'product',
'ref_ext' => array('name'=>'ref_ext','type'=>'xsd:string'), 'type' => 'tns:product',
'minOccurs' => '0',
'maxOccurs' => 'unbounded'
)
) )
); );
// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped // 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. // 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/ // http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
@ -189,7 +204,7 @@ $server->register(
// Entry values // Entry values
array('authentication'=>'tns:authentication','filterproduct'=>'tns:filterproduct'), array('authentication'=>'tns:authentication','filterproduct'=>'tns:filterproduct'),
// Exit values // Exit values
array('result'=>'tns:result','arrayproducts'=>'tns:arrayproducts'), array('result'=>'tns:result','products'=>'tns:ProductsArray2'),
$ns, $ns,
$ns.'#getListOfProductsOrServices', $ns.'#getListOfProductsOrServices',
$styledoc, $styledoc,
@ -445,7 +460,7 @@ function getListOfProductsOrServices($authentication,$filterproduct)
while ($i < $num) while ($i < $num)
{ {
$obj=$db->fetch_object($resql); $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++; $i++;
} }
} }
@ -461,17 +476,17 @@ function getListOfProductsOrServices($authentication,$filterproduct)
{ {
$objectresp = array( $objectresp = array(
'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel), 'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel),
'arrayproducts'=>$arrayproducts 'products'=>$arrayproducts
); );
} }
else else
{ {
$objectresp = array( $objectresp = array(
'result'=>array('result_code' => 'OK', 'result_label' => ''), 'result'=>array('result_code' => 'OK', 'result_label' => ''),
'arrayproducts'=>$arrayproducts 'products'=>$arrayproducts
); );
} }
var_dump($objectresp);exit;
return $objectresp; return $objectresp;
} }