Ver Mensaje Individual
  #2 (permalink)  
Antiguo 01/09/2010, 13:24
vega_012
 
Fecha de Ingreso: noviembre-2008
Ubicación: Lima
Mensajes: 48
Antigüedad: 15 años, 5 meses
Puntos: 2
De acuerdo Respuesta: Nusoap Variables de Entrada

bueno muchacho espero que te sirva el codigo que te envio. en la cual envio 3 parametros de las cuales el primero es un array. espero te sirva y saludos de aqui nomas de peru

cliente
--------
require('lib/nusoap.php');
set_time_limit("120000");
$client = new soapclient('http://localhost:81/webservice/servidor.php?wsdl', 'wsdl');
//producto
$producto[0] = array(
'idservicio' =>'1',
'id_orden' =>'2' ,
'contenido'=>'refrigeradora',
'peso'=>'12.5',
'piezas'=>'1',
'dimension'=>'12x15',
'id_reco'=>'45',
'contacto_reco'=>'junior',
'tlf_contacto'=>'1234567',
'dest'=>'piura',
'dir'=>'jr piura 245',
'ref'=>'colegio porras',
'ubigeo'=>'152365',
'tlf_entrega'=>'1598765',
'fecha_entrega'=>date('d/m/Y'),
'hora_desde'=>date('H:i'),
'hora_hasta'=>date('H:i')
);
$producto[1] = array(
'idservicio' => 2,
'id_orden' => 3,
'contenido'=>'televisor',
'peso'=>'10',
'piezas'=>'1',
'dimension'=>'15x10',
'id_reco'=>'62',
'contacto_reco'=>'paul',
'tlf_contacto'=>'7896541',
'dest'=>'lima',
'dir'=>'jr pariñas 451',
'ref'=>'colegio clr',
'ubigeo'=>'123487',
'tlf_entrega'=>'9512358',
'fecha_entrega'=>date('d/m/Y'),
'hora_desde'=>date('H:i'),
'hora_hasta'=>date('H:i')
);
//cliente
$shipper="RIPLEY";
$remitente="salvador vega reyes";
$email="[email protected]";

$result = $client->call('venta', array('productos' => $producto,'shipper'=>$cliente,'remitente'=>$remite nte,'email'=>$email));
var_export($result);

servidor.php
----------------
//1.- Incluimos la libreria nusoap dentro de nuestro archivo
include ('lib/nusoap.php');
set_time_limit("120000");
//2.- Creamos la instancia al servidor
$server = new soap_server();
//3.- Inicializamos el soporte WSDL
$server->configureWSDL('ProcederVenta', 'urn:ProcederVenta');
// Parametros de entrada
$server->wsdl->addComplexType(
'Productos',
'complexType',
'struct',
'all',
'',
array(
'idservicio' => array('name' => 'idservicio', 'type' => 'xsd:string'),
'id_orden' => array('name' => 'id_orden', 'type' => 'xsd:string'),
'contenido'=>array('name' => 'contenido', 'type' => 'xsd:string'),
'peso'=>array('name' => 'peso', 'type' => 'xsd:string'),
'piezas'=>array('name' => 'piezas', 'type' => 'xsd:string'),
'dimension'=>array('name' => 'dimension', 'type' => 'xsd:string'),
'id_reco'=>array('name' => 'id_reco', 'type' => 'xsd:string'),
'contacto_reco'=>array('name' => 'contacto_reco', 'type' => 'xsd:string'),
'tlf_contacto'=>array('name' => 'tlf_contacto', 'type' => 'xsd:string'),
'dest'=>array('name' => 'dest', 'type' => 'xsd:string'),
'dir'=>array('name' => 'dir', 'type' => 'xsd:string'),
'ref'=>array('name' => 'ref', 'type' => 'xsd:string'),
'ubigeo'=>array('name' => 'ubigeo', 'type' => 'xsd:string'),
'tlf_entrega'=>array('name' => 'tlf_entrega', 'type' => 'xsd:string'),
'fecha_entrega'=>array('name' => 'fecha_entrega', 'type' => 'xsd:string'),
'hora_desde'=>array('name' => 'hora_desde', 'type' => 'xsd:string'),
'hora_hasta'=>array('name' => 'hora_hasta', 'type' => 'xsd:string')
)
);
$server->wsdl->addComplexType('arrayEntrada',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(
array('ref' => 'SOAP-ENC:arrayType',
'wsdl:arrayType' => 'tns:Productos[]')
),
'tns:Productos'
);
// Parametros de salida
$server->wsdl->addComplexType(
'Respuesta',
'complexType',
'struct',
'all',
'',
array(
'result' => array('name' => 'result', 'type' => 'xsd:string'),
'msg' => array('name' => 'msg', 'type' => 'xsd:string'),
'cesta' => array('name' => 'cesta', 'type' => 'xsd:string'),
'guia' => array('name' => 'guia', 'type' => 'xsd:string')
)
);
//
$server->register('venta', // method name
array('productos' => 'tns:arrayEntrada','shipper'=>'xsd:string','remite nte'=>'xsd:string','email'=>'xsd:string'), // input parameters
array('return' => 'tns:Respuesta'), // output parameters
'urn:ProcederVenta', // namespace
'urn:ProcederVenta#venta', // soapaction
'rpc', // style
'encoded', // use
'proceso de envio' // documentation
);
//
function venta($productos,$shipper,$remitente,$email) {
$file=fopen('compras.txt','w+');
foreach($productos as $producto){
$datos.=implode(',',$producto)."\n";
}
fwrite($file,$datos);
fclose($file);
$resultado="bien";
$msg="1";
$cesta="15";
$guia="12547";
return array(
'result' => $resultado,
'msg' => $msg,
'cesta' => $cesta,
'guia' => $guia
);
}
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);