Quisiera saber si es posible chequear desde donde realiza una petición atravez de SOAP.
Planteo aqui me jemplo de soap aprovechando tambien utilizo un ejemplo en el que la petición es devuelta como un array...
Esto funciona con nusoap toolkit, si lo desean pueden bajarlo de:
http://sourceforge.net/projects/nusoap/
cliente.php
Código PHP:
<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the client instance
$client = new soapclient('http://localhost/soap/servicio.php');
// Check for an error
$err = $client->getError();
if ($err) {
// Display the error
echo '<p><b>Constructor error: ' . $err . '</b></p>';
// At this point, you know the call that follows will fail
}
// Call the SOAP method
$names = array('Scott', 'Albert', 'Robert', 'Phyllis');
$result = $client->call(
'hello', // method name
array('names' => $names) // input parameters
);
// Check for a fault
if ($client->fault) {
echo '<p><b>Fault: ';
print_r($result);
echo '</b></p>';
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error
echo '<p><b>Error: ' . $err . '</b></p>';
} else {
// Display the result
print_r($result);
}
}
?>
Código PHP:
<?php
// Pull in the NuSOAP code
require_once('lib/nusoap.php');
// Create the server instance
$server = new soap_server;
// Register the method to expose
// Note: with NuSOAP 0.6.3, only method name is used w/o WSDL
$server->register(
'hello' // method name
);
// Define the method as a PHP function
function hello($names) {
for ($i = 0; $i < count($names); $i++) {
$retval[$i] = 'Hello, ' . $names[$i]; //$_SERVER['PHP_SELF']
}
$retval[count($retval)+1] = $_SERVER['REQUEST_URI'];
return $retval;
}
// Use the request to (try to) invoke the service
$HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>