Web service with PHP + nusoap [closed]

1

Good evening,

I need your help to understand how to create a webservice using the "library" nusoap , I have seen many examples with code, but they do not explain what each parameter means, so if I have to modify it , even if it's the least bit, it does not work for me anymore.

    //Incluye a toolkit
require_once 'lib/nusoap.php';
//Instancia al servidor
$server = new nusoap_server();

$server->configureWSDL('Prueba sobre WS', 'urn:pr');

//Parametros de entrada
$server->wsdl->addComplexType('datos_entrada',
                              'complexType',
                              'struct', 
                              'all',
                              '',
                              array('pais'=>array('name'=>'pais', 'type'=>'wsl:string'),
                                    'ciudad'=>array('name'=>'ciudad', 'type'=>'wsl:string')
                                   )
                             );

//Parametros de salida
$server->wsdl->addComplexType('datos_salida',
                              'complexType',
                              'struct', 
                              'all',
                              '',
                              array('mensaje'=>array('name'=>'mensaje', 'type'=>'wsl:string')
                                   )
                             );

//Registrar las funciones
$server->register(
                    'gettime',
                    array('datos_entrada'=>'tns:datos_entrada'),
                    array('return'=>'xsd:string'),
                    'urn:pr',
                    'urn:pr#gettime',
                    'rpc',  
                    'encoded',
                    'Return time'
                 );


//Invocar
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);

//Funciones

function gettime($datos){
    return 'nublado';
}

I have some questions:

1- Is it obligatory to define the input and output parameters? or just put as information

2- What is urn? I have seen that many there put a variable $ namespace, but what is $ namespace ?, that is, what exactly should I name? name of my php class, domain name, or what?

3- What is "tns" and "xsd"?

4- "complexType" and "struct" can they take other values? If so, when? And which?

5- If I have classes on my server, how do I register their methods?

I would like to know if I should receive a parameter or many, or maybe return a variable, a code or many values, I currently have no idea how to register it.

I have been trying for several hours, but I can not move forward, I would like someone to explain it to me, and if you can give me an example code it would be great, with variables where you have to modify the value.

Last question, what do you do online?

$ HTTP_RAW_POST_DATA = isset ($ HTTP_RAW_POST_DATA)? $ HTTP_RAW_POST_DATA: '';

    
asked by Strelok 26.01.2018 в 00:59
source

0 answers