exécuter plus qu'une methode avec ksoap2 web services j2me
bonjour tout le monde
bon comme c'est indique dans le titre je veut exécuter plus qu'une methode d'un web service je j'ai crée bon voici le code java
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
public class UtilisationKSOAP2 extends MIDlet
{
private Form monFormulaire;
private Display affichage;
private StringBuffer tamponEcriture;
public UtilisationKSOAP2()
{
super();
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException
{
this.notifyDestroyed();
}
protected void pauseApp()
{
//
}
protected void startApp() throws MIDletStateChangeException
{
// gestion de l'affichage
this.affichage = Display.getDisplay(this);
this.monFormulaire = new Form("KSOAP2 exemple");
// StringBuffer pour debug
this.tamponEcriture = new StringBuffer("Journal des évènements\n");
this.executerRequeteSOAP();
}
public void afficherResultat()
{
this.monFormulaire .append ( this.tamponEcriture.toString() );
this.affichage .setCurrent(this.monFormulaire);
}
private void executerRequeteSOAP ()
{
// partie de la création des objets HTTPTransport et SOAPObject
Object resultatRequeteSOAP = null;
SoapObject objetSOAPHello;
HttpTransport connexionServeur;
SoapSerializationEnvelope envelope ;
// nom du service
String nomService = "nom du service";
// url du service
String urlService= "url web service";
// méthode du service
String methodeChoisie = "connection";
try
{
this.tamponEcriture .append("création HTTPTransport\n");
// etape 1 création module de connexion HTTP
connexionServeur = new HttpTransport ( urlService );
//TODO a modifier lors de la mise en production
connexionServeur.debug = true;
// etape 1 ok
this.tamponEcriture .append("creation HTTPTransport effective\n");
// création objet SOAP
objetSOAPHello = new SoapObject (nomService, methodeChoisie );
objetSOAPHello .addProperty ("login","mylogin");
objetSOAPHello .addProperty ("password", "mypass");
// création d'un objet qui contiendra nos propriétés
envelope = new SoapSerializationEnvelope(SoapSerializationEnvelope.VER11);
envelope.bodyOut = objetSOAPHello;
// argument utile dans le cas d'un service SOAP .net
//envelope.dotNet = true;
// création de l'objet SOAP ok
this.tamponEcriture .append("SOAPobjet effective\n");
}
catch (Exception aE)
{
this.tamponEcriture .append("Exception levée dans SOAPObject\n");
this.afficherResultat();
aE.printStackTrace ();
return;
}
// connexion au serveur
try
{
// invoquation de la méthode sur le serveur
connexionServeur.call(nomService, envelope);
// recuperation de la réponse du serveur
resultatRequeteSOAP = envelope.getResponse();
// affichage de la réponse
this.tamponEcriture .append("resultat de la requête\n");
this.tamponEcriture .append(resultatRequeteSOAP);
this.afficherResultat();
}
catch (Exception aE)
{
this.tamponEcriture .append("exception déclenchée sur méthode call\n"+connexionServeur.responseDump);
//System.out.print(connexionServeur.responseDump.getClass());
this.afficherResultat();
aE.printStackTrace();
}
}
} |
alors comme c'est indique ce code permet d'authentifier la personne qui veut se connecter mais je veut qu'après la connection il consulte des tels choses à travers des autres methodes bien sur comme "voircontrat" alors ma question c'est est ce que à chaque foi que je veut exécuter une methodes il faut faire tout ça ?