PC SOFT

GRUPOS DE DISCUSSÃO PROFISSIONAL
WINDEVWEBDEV e WINDEV Mobile

Inicio → WINDEV Mobile (versões anteriores) → Problème application android et l'utilisation d'un webservice
Problème application android et l'utilisation d'un webservice
Iniciado por polowaka, abr., 08 2016 8:36 AM - 3 respostas
Membro registado
2 mensagems
Publicado em abril, 08 2016 - 8:36 AM
Bonjour à tous

Je suis actuellement sur un projet qui consiste à créer une application mobile, j'ai donc créé cette application sur windevMobile20 .

A l'aide du simulateur je peux tester l'ensemble de mon application , sans avoir aucun soucis.
Mon application nécessite un webservice que j'utilise grâce à un fichier WSDL fournit par un de mes collègues de projet.

Mon problème étant que lors de la compilation sur le téléphone tout fonctionne , lors de l'utilisation de l'application rien ne plante , mais des le premier appel d'une méthode de ce Webservice mon applicaiton m'affiche un message d'erreur en me disant qu'il ne trouve pas la méthode du webservice....

je ne comprend donc pas d'ou cela provient et j'espère que quelqu'un saura comment me débloquer ce problème ..

Cordialement
Merci d'avance.
Membro registado
84 mensagems
Popularité : +2 (2 votes)
Publicado em abril, 08 2016 - 9:16 AM
sans code, et contenu de la webservice, ça va être difficile de t'aider...

--
SPEETBOX by STARCK - SPEETA
Membro registado
2 mensagems
Publicado em abril, 08 2016 - 10:28 AM
Voici le code du client.php pour le serveur soap

<?php
// refresh de la page
//header("Refresh: 2;");

// Désactivation du cache WSDL
ini_set("soap.wsdl_cache_enabled", "0");

$options = array('uri'=> 'http://172.17.50.155/websocket/webservice/');
$client = new SoapClient("getserverservice.wsdl");
try {
// Demande de connexion => récupère des adresse Mac
$Id ='Erwan';
$Password='7110eda4d09e062aa5e4';
echo "Demande de connexion 1 : ";
echo $client->Authentification($Id, $Password);

echo "<br> <br> <br> ";
$Id ='zefd';
$Password='787';
echo "Demande de connexion 2 : ";
echo $client->Authentification($Id, $Password);

// Changement des etats des prises
echo "<br> <br> <br> ";
$Identifiant ='Erwan';
$Mac='18:fe:34:e4:c1:47';
$Broche='510001';
echo "Adresse Mac prise : $Mac <br> Broche : $Broche";
echo "<br> ";
echo $client->Modification($Identifiant, $Mac, $Broche);

// Changement de mot de passe
echo "<br> <br> <br> ";
$Id ='Chaki';
$NewPassword='blabla';
echo $client->Mot_de_passe($Id, $NewPassword);

//Affichage des etats courant
echo "<br> <br> <br> ";
$Mac ='91-70-1B-DC-9E-FF';
echo $client->Etat_courant($Mac);

} catch (SoapFault $exception) {
echo $exception;
}
?>

voici le code du server.php

<?php
// prevent the server from timing out
set_time_limit(0);
// include the web sockets server script (the server is started at the far bottom of this file)
require 'class.PHPWebSocket.php';
// when a client sends data to the server
function wsOnMessage($clientID, $message, $messageLength, $binary) {
global $Server;
if (is_numeric($message[0])==true || ctype_alpha($message[0])==true)
{
$bdd = new PDO('mysql:host=localhost;dbname=domotique;charset=utf8', 'root', '');
$reponse = $bdd->query("UPDATE prise SET IDWeb = '$clientID' WHERE Mac ='$message'");
$Server->log("Enregistrement a ladresse : $message de l ID : $clientID");
}

//Si on envoie addresse mac et et message envoief4:b5
if($message[0]=='#')
{
$Mac= substr($message, 1, 19);
$bdd = new mysqli("localhost", "root", "", "domotique");
$reponseID = $bdd->query("SELECT IDWeb FROM prise WHERE Mac ='$Mac'");
$reponseBool = $bdd->query("SELECT EtatBool1, EtatBool2, EtatBool3,EtatBool4 ,EtatBool5 FROM prise WHERE Mac='$Mac'");
$IDrecup = $reponseID->fetch_row();
$Etatrecup = $reponseBool->fetch_row();//Envoyer les donnes sout forme d'un octet
$Donne="$Etatrecup[0]$Etatrecup[1]$Etatrecup[2]$Etatrecup[3]$Etatrecup[4]";//Concatenation de la chaine de donne
$Server->wsSend($IDrecup[0], "$Donne");
$Server->log("Information Envoyer: $Donne");
}
}
// when a client connects
function wsOnOpen($clientID)
{
global $Server;
$ip = long2ip( $Server->wsClients[$clientID][6] );
$Server->log( "$ip ($clientID) has connected." );

}
// when a client closes or lost connection
function wsOnClose($clientID, $status) {
global $Server;
$ip = long2ip( $Server->wsClients[$clientID][6] );
$Server->log( "$ip ($clientID) is disconnected." );
}
// start the server
$Server = new PHPWebSocket();
$Server->bind('message', 'wsOnMessage');
$Server->bind('open', 'wsOnOpen');
$Server->bind('close', 'wsOnClose');
$Server->log( "Serveur lance" );
// for other computers to connect, you will probably need to change this to your LAN IP or external IP,
// alternatively use: gethostbyaddr(gethostbyname($_SERVER['SERVER_NAME']))
$Server->wsStartServer('0.0.0.0', 9300);
?>



et voici le code de mon fichier.wsdl

<?xml version ='1.0' encoding ='UTF-8' ?>
<definitions name='server'
targetNamespace='http://172.17.50.152/SOAP/server.php'
xmlns:tns='http://172.17.50.152/SOAP/server.php'
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='GetModificationRequest'>
<part name='Identification' type='xsd:string'/>
<part name='Mac' type='xsd:string'/>
<part name='N_prise' type='xsd:int'/>
<part name='Etat' type='xsd:boolean'/>
</message>
<message name='GetModificationResponse'>
<part name='resultat' type='xsd:string'/>
</message>
<message name='GetAuthRequest'>
<part name='Id' type='xsd:string'/>
<part name='Password' type='xsd:string'/>
</message>
<message name='GetAuthResponse'>
<part name='resultat' type='xsd:string'/>
</message>
<message name='GetPassRequest'>
<part name='Id' type='xsd:string'/>
<part name='NewPassword' type='xsd:string'/>
</message>
<message name='GetPassResponse'>
<part name='resultat' type='xsd:string'/>
</message>
<message name='GetEtatRequest'>
<part name='Mac' type='xsd:string'/>
</message>
<message name='GetEtatResponse'>
<part name='resultat' type='xsd:string'/>
</message>
<message name='GetEpheRequest'>
<part name='Mac' type='xsd:string'/>
<part name='N_prise' type='xsd:int'/>
<part name='Nb-Ephe' type='xsd:int'/>
<part name='Plannif' type='xsd:string'/>
</message>
<message name='GetEpheResponse'>
<part name='resultat' type='xsd:string'/>
</message>
<message name='GetEtatEpheRequest'>
<part name='Mac' type='xsd:string'/>
<part name='N_prise' type='xsd:int'/>
<part name='Nb-Ephe' type='xsd:int'/>
</message>
<message name='GetEtatEpheResponse'>
<part name='resultat' type='xsd:string'/>
</message>

<portType name='GetServerPortType'>
<operation name='Modification'>
<input message='tns:GetModificationRequest'/>
<output message='tns:GetModificationResponse'/>
</operation>
<operation name='Authentification'>
<input message='tns:GetAuthRequest'/>
<output message='tns:GetAuthResponse'/>
</operation>
<operation name='Mot_de_passe'>
<input message='tns:GetPassRequest'/>
<output message='tns:GetPassResponse'/>
</operation>
<operation name='Etat_courant'>
<input message='tns:GetEtatRequest'/>
<output message='tns:GetEtatResponse'/>
</operation>
<operation name='Ephemeride'>
<input message='tns:GetEpheRequest'/>
<output message='tns:GetEpheResponse'/>
</operation>
<operation name='Etat_courant_ephemeride'>
<input message='tns:GetEtatEpheRequest'/>
<output message='tns:GetEtatEpheResponse'/>
</operation>
</portType>

<binding name='GetServerBinding' type='tns:GetServerPortType'>
<soap:binding style='rpc' transport='http://schemas.xmlsoap.org/soap/http'/>
<operation name='Modification'>
<soap:operation soapAction='urn:xmethods-delayed-quotes#Modification'/>
<input>
<soap:body use='encoded' namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
<operation name='Authentification'>
<soap:operation soapAction='urn:xmethods-delayed-quotes#Authentification'/>
<input>
<soap:body use='encoded' namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
<operation name='Mot_de_passe'>
<soap:operation soapAction='urn:xmethods-delayed-quotes#Mot_de_passe'/>
<input>
<soap:body use='encoded' namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
<operation name='Etat_courant'>
<soap:operation soapAction='urn:xmethods-delayed-quotes#Etat_courant'/>
<input>
<soap:body use='encoded' namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
<operation name='Ephemeride'>
<soap:operation soapAction='urn:xmethods-delayed-quotes#Ephemeride'/>
<input>
<soap:body use='encoded' namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
<operation name='Etat_courant_ephemeride'>
<soap:operation soapAction='urn:xmethods-delayed-quotes#Etat_courant_ephemeride'/>
<input>
<soap:body use='encoded' namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input>
<output>
<soap:body use='encoded' namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output>
</operation>
</binding>

<service name='GetServerService'>
<port name='GetServerPort' binding='GetServerBinding'>
<soap:address location='http://localhost/webservice/server.php'/>
</port>
</service>
</definitions>




Alors ma question serai surtout pourquoi le simulateur arrive à fonctionner tandis que le téléphone non :/

Merci d'avance
Publicado em abril, 08 2016 - 12:51 PM
Bonjour

je ne vois pas bien ce que du code php vient faire dans une appli
mobile, mais bon...

La différence MAJEURE entre simulateur et hardware est le type de
chaines: ANSI en simulateur (comme dans ton webservice, je suppose, et
donc compatible) et UNICODE dans ton appli mobile. Change les chaines
utilisés en chaine ansi et ca devrait fonctionner nettement mieux.

Cordialement


--
Fabrice Harari
Consultant WinDev, WebDev et WinDev Mobile International

A votre disposition : WXShowroom.com, WXReplication (open source) et
maintenant WXEDM (open source)

Plus d'information sur http://fabriceharari.com


On 4/8/2016 2:28 AM, polowaka wrote:
Voici le code du client.php pour le serveur soap

<?php
// refresh de la page
//header("Refresh: 2;");
// Désactivation du cache WSDL
ini_set("soap.wsdl_cache_enabled", "0");
$options = array('uri'=>
'http://172.17.50.155/websocket/webservice/');
$client = new SoapClient("getserverservice.wsdl"); try {
// Demande de connexion => récupère des adresse Mac
$Id ='Erwan';
$Password='7110eda4d09e062aa5e4';
echo "Demande de connexion 1 : ";
echo $client->Authentification($Id, $Password);

echo "<br> <br> <br> ";
$Id ='zefd';
$Password='787';
echo "Demande de connexion 2 : ";
echo $client->Authentification($Id, $Password);

// Changement des etats des prises
echo "<br> <br> <br> ";
$Identifiant ='Erwan';
$Mac='18:fe:34:e4:c1:47';
$Broche='510001';
echo "Adresse Mac prise : $Mac <br> Broche : $Broche";
echo "<br> ";
echo $client->Modification($Identifiant, $Mac, $Broche);
// Changement de mot de passe
echo "<br> <br> <br> ";
$Id ='Chaki';
$NewPassword='blabla';
echo $client->Mot_de_passe($Id, $NewPassword);

//Affichage des etats courant echo "<br> <br> <br> ";
$Mac ='91-70-1B-DC-9E-FF';
echo $client->Etat_courant($Mac);

} catch (SoapFault $exception) { echo $exception; } ?>

voici le code du server.php

<?php
// prevent the server from timing out
set_time_limit(0);
// include the web sockets server script (the server is started at the
far bottom of this file)
require 'class.PHPWebSocket.php';
// when a client sends data to the server
function wsOnMessage($clientID, $message, $messageLength, $binary) {
global $Server;
if (is_numeric($message[0])==true || ctype_alpha($message[0])==true)
{
$bdd = new
PDO('mysql:host=localhost;dbname=domotique;charset=utf8', 'root', '');
$reponse = $bdd->query("UPDATE prise SET IDWeb = '$clientID'
WHERE Mac ='$message'");
$Server->log("Enregistrement a ladresse : $message de l ID :
$clientID");
}

//Si on envoie addresse mac et et message envoief4:b5
if($message[0]=='#')
{
$Mac= substr($message, 1, 19);
$bdd = new mysqli("localhost", "root", "", "domotique");
$reponseID = $bdd->query("SELECT IDWeb FROM prise WHERE Mac
='$Mac'");
$reponseBool = $bdd->query("SELECT EtatBool1, EtatBool2,
EtatBool3,EtatBool4 ,EtatBool5 FROM prise WHERE Mac='$Mac'");
$IDrecup = $reponseID->fetch_row();
$Etatrecup = $reponseBool->fetch_row();//Envoyer les donnes
sout forme d'un octet

$Donne="$Etatrecup[0]$Etatrecup[1]$Etatrecup[2]$Etatrecup[3]$Etatrecup[4]";//Concatenation
de la chaine de donne
$Server->wsSend($IDrecup[0], "$Donne");
$Server->log("Information Envoyer: $Donne");
}
}
// when a client connects
function wsOnOpen($clientID)
{
global $Server;
$ip = long2ip( $Server->wsClients[$clientID][6] );
$Server->log( "$ip ($clientID) has connected." );

}
// when a client closes or lost connection
function wsOnClose($clientID, $status) {
global $Server;
$ip = long2ip( $Server->wsClients[$clientID][6] );
$Server->log( "$ip ($clientID) is disconnected." );
}
// start the server
$Server = new PHPWebSocket();
$Server->bind('message', 'wsOnMessage');
$Server->bind('open', 'wsOnOpen');
$Server->bind('close', 'wsOnClose');
$Server->log( "Serveur lance" );
// for other computers to connect, you will probably need to change this
to your LAN IP or external IP,
// alternatively use: gethostbyaddr(gethostbyname($_SERVER['SERVER_NAME']))
$Server->wsStartServer('0.0.0.0', 9300);
?>



et voici le code de mon fichier.wsdl

<?xml version ='1.0' encoding ='UTF-8' ?> <definitions name='server'
targetNamespace='http://172.17.50.152/SOAP/server.php'
xmlns:tns='http://172.17.50.152/SOAP/server.php'
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='GetModificationRequest'> <part
name='Identification' type='xsd:string'/>
<part name='Mac' type='xsd:string'/>
<part name='N_prise' type='xsd:int'/>
<part name='Etat' type='xsd:boolean'/>
</message> <message name='GetModificationResponse'> <part
name='resultat' type='xsd:string'/> </message> <message
name='GetAuthRequest'> <part name='Id' type='xsd:string'/>
<part name='Password' type='xsd:string'/>
</message> <message name='GetAuthResponse'> <part
name='resultat' type='xsd:string'/>
</message> <message name='GetPassRequest'> <part
name='Id' type='xsd:string'/>
<part name='NewPassword' type='xsd:string'/>
</message> <message name='GetPassResponse'> <part
name='resultat' type='xsd:string'/>
</message> <message name='GetEtatRequest'>
<part name='Mac' type='xsd:string'/>
</message> <message name='GetEtatResponse'> <part
name='resultat' type='xsd:string'/>
</message> <message name='GetEpheRequest'>
<part name='Mac' type='xsd:string'/>
<part name='N_prise' type='xsd:int'/>
<part name='Nb-Ephe' type='xsd:int'/>
<part name='Plannif' type='xsd:string'/>
</message> <message name='GetEpheResponse'> <part
name='resultat' type='xsd:string'/>
</message>
<message name='GetEtatEpheRequest'>
<part name='Mac' type='xsd:string'/>
<part name='N_prise' type='xsd:int'/>
<part name='Nb-Ephe' type='xsd:int'/>
</message> <message name='GetEtatEpheResponse'> <part
name='resultat' type='xsd:string'/>
</message>

<portType name='GetServerPortType'> <operation
name='Modification'> <input
message='tns:GetModificationRequest'/> <output
message='tns:GetModificationResponse'/> </operation>
<operation name='Authentification'> <input
message='tns:GetAuthRequest'/> <output
message='tns:GetAuthResponse'/> </operation>
<operation name='Mot_de_passe'> <input
message='tns:GetPassRequest'/> <output
message='tns:GetPassResponse'/> </operation>
<operation name='Etat_courant'> <input
message='tns:GetEtatRequest'/> <output
message='tns:GetEtatResponse'/> </operation>
<operation name='Ephemeride'> <input
message='tns:GetEpheRequest'/> <output
message='tns:GetEpheResponse'/> </operation>
<operation name='Etat_courant_ephemeride'> <input
message='tns:GetEtatEpheRequest'/> <output
message='tns:GetEtatEpheResponse'/> </operation>
</portType>
<binding name='GetServerBinding' type='tns:GetServerPortType'>
<soap:binding style='rpc'
transport='http://schemas.xmlsoap.org/soap/http'/> <operation
name='Modification'> <soap:operation
soapAction='urn:xmethods-delayed-quotes#Modification'/> <input>
<soap:body use='encoded'
namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input> <output> <soap:body use='encoded'
namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output> </operation>
<operation name='Authentification'> <soap:operation
soapAction='urn:xmethods-delayed-quotes#Authentification'/>
<input> <soap:body use='encoded'
namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input> <output> <soap:body use='encoded'
namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output> </operation>
<operation name='Mot_de_passe'> <soap:operation
soapAction='urn:xmethods-delayed-quotes#Mot_de_passe'/> <input>
<soap:body use='encoded'
namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input> <output> <soap:body use='encoded'
namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output> </operation>
<operation name='Etat_courant'> <soap:operation
soapAction='urn:xmethods-delayed-quotes#Etat_courant'/> <input>
<soap:body use='encoded'
namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input> <output> <soap:body use='encoded'
namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output> </operation>
<operation name='Ephemeride'> <soap:operation
soapAction='urn:xmethods-delayed-quotes#Ephemeride'/> <input>
<soap:body use='encoded'
namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input> <output> <soap:body use='encoded'
namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output> </operation> <operation
name='Etat_courant_ephemeride'> <soap:operation
soapAction='urn:xmethods-delayed-quotes#Etat_courant_ephemeride'/>
<input> <soap:body use='encoded'
namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</input> <output> <soap:body use='encoded'
namespace='urn:xmethods-delayed-info'
encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'/>
</output> </operation>
</binding>
<service name='GetServerService'> <port name='GetServerPort'
binding='GetServerBinding'> <soap:address
location='http://localhost/webservice/server.php'/> </port>
</service> </definitions>




Alors ma question serai surtout pourquoi le simulateur arrive à
fonctionner tandis que le téléphone non :/

Merci d'avance