Aller au contenu
View in the app

A better way to browse. Learn more.

Next

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Client SOAP

Featured Replies

Posté(e)

Salut amis INpactiens :transpi:

Je bosse actuellement sur un projet et je réalise en ce moment une archi client-serveur basée sur les webservices et notamment le protocole SOAP.

J'ai déjà un serveur 100% fonctionnel qui renvoie les bonnes données.

J'aimerais savoir comment récupérer dans mon client ces données formattées avec le WSDL.

Si quelqu'un a une idée je suis preneur ! :-D

...parceque moi, je galère :transpi:

Bonne aprem à tous !

Je me permets de vous mettre mon code histoire que vous puissiez voir de quoi ca parle !

service1_ping.wsdl

<?xml version ='1.0' encoding ='UTF-8' ?>

<definitions name='StockPing'

 targetNamespace='http://example.org/StockPing'
 xmlns:tns=' http://example.org/StockPing '
 xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
 xmlns:xsd='http://www.w3.org/2001/XMLSchema'
 xmlns:soapenc='http://schemas.xmlsoap.org/soap/encoding/'
 xmlns:wsdl='http://schemas.xmlsoap.org/wsdl/'
 xmlns='http://schemas.xmlsoap.org/wsdl/'>

<message name='getPingRequest'>
 <part name='address' type='xsd:string'/>
 <part name='timeout' type='xsd:string'/>
 <part name='count' type='xsd:string'/>
 <part name='intervalle' type='xsd:string'/>
 <part name='packetsize' type='xsd:string'/>
</message>

<message name='getPingResponse'>
 <part name='success' type='xsd:string'/>
 <part name='min' type='xsd:string'/>
 <part name='max' type='xsd:string'/>
 <part name='avg' type='xsd:string'/>
</message>

<portType name='StockPingPortType'>
 <operation name='getPing'>
<input message='tns:getPingRequest'/>
<output message='tns:getPingResponse'/>
 </operation>
</portType>

<binding name='StockPingBinding' type='tns:StockPingPortType'>
 <soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/>
 <operation name='getPing'>
<soap:operation soapAction='urn:xmethods-delayed-quotes#getPing'/>
<input>
  <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
	encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
  <soap:body use='encoded' namespace='urn:xmethods-delayed-quotes'
	encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
 </operation>
</binding>

<service name='StockPingService'>
 <port name='StockPingPort' binding='StockPingBinding'>
<soap:address location='http://172.22.9.55/kpi_test/server1_ping.php'/>
 </port>
</service>

</definitions>

server1_ping.php qui marche !

<?php

// Appel fonction et instanciation d'un serveur

ini_set("soap.wsdl_cache_enabled", "0"); // disabling WSDL cache
$server = new SoapServer("service1_ping.wsdl");
$server->addFunction("getPing");
$server->addFunction(array("getPing","echoTwoStrings"));
$server->addFunction(SOAP_FUNCTIONS_ALL);
$server->handle();


// Fonction qui appelle le script bash pour effectuer le ping

function getPing($destination_ip, $timeout, $count, $intervalle, $packetsize)
{
 $cmd="/export/home/www/kpi_test/ping1.sh $destination_ip $timeout $count $intervalle $packetsize";
 $val=system($cmd, $res);
 $val2 = explode(" ",$val);

 // Recuperation des valeurs du min, max, avg, lost
 $inputString1=$val2[0]; // min
 $inputString2=$val2[1];  // avg
 $inputString3=$val2[2];  // max
 $inputString4=$val2[3];   // % lost

 return array($inputString1,$inputString2,$inputString3,$inputString4);
}

// Fonction qui insere les donnees dans le wsdl

function echoTwoStrings($inputString1, $inputString2, $inputString3, $inputString4)
{
return array("success" => $inputString1,"min" => $inputString2, "max" => $inputString3, "avg" => $inputString4 );
}


?>

client1_ping.php qui n'est toujours pas fonctionnel... Impossible de récup les données du fichier WSDL

<?php

 include("connection.php");

 $destination_ip=$_POST['destination_ip'];

 // Si champ adresse rempli
 if(!empty($destination_ip))
 {

  // Recherche des elements dans la base
$Query="select id, timeout, count, intervalle, packetsize from icmp where icmp.id=1";
	$resultat = mysql_query($Query, $connexion);
	$data = mysql_fetch_assoc($resultat);

	// Recuperation des elements de la bdd
	$timeout=$data['timeout'];
	$count=$data['count'];
	$intervalle=$data['intervalle'];
	$packetsize=$data['packetsize'];

$client = new SoapClient("service1_ping.wsdl",array("trace" => 1,"exceptions" => 0));

// Appel a la fonction getPing du serveur
	$client->getPing($destination_ip, $timeout, $count, $intervalle, $packetsize);

	// Recuperation des valeurs
	//$client->__soapCall("getPingResponse",array($response));

	//$server->addFunction(array("getPing","echoTwoStrings"));
	//$response = $client->__soapCall("getInfoVoip",array($wrapper));

	// Affichage de la reponse du serveur
	echo " resultat : $response";
	echo "<br>";
/*

	echo "Adresse : $address";
	echo "<br>";
	echo "Success : $success";
	echo "<br>";
	echo "Min : $min";
	echo "<br>";
	echo "Max : $max";
	echo "<br>";
	echo "AVG : $avg";
	echo "<br>";
	echo "LOST : $lost";
	echo "<br>";
	echo "Cet enregistrement a bien été ajouté en base";
	*/
	# Requete d'insertion dans la base de donnees
	$Query_1="insert into result(id, timestamp, success, mini, maxi, moy, lost)values ('1',now(),'$success','$min','$max','$avg','$lost')";
	$dbResult = mysql_query($Query_1, $connexion);

	echo "<br>";
	print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
	echo "<br>";
	echo "<br>";
	print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";

 }


 // Si champ adresse non rempli
 if(empty($destination_ip))
 {
	echo 'entrer une adresse ip svp';
 }

	//print "Resultat : $result \n";


	//$db = mysql_connect('localhost','root','SuperSql');
	//$dat= mysql_select_db('kpi',$db);
	//$sql="INSERT INTO adresse VALUES ('','$destination_ip')";
	//$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
	//mysql_close();

	?>
	<br>
	<A HREF="index.php">Retour</A>

Modifié par NiceOne

  • 2 mois après...

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.