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
| public WebServ(){
tamponEcriture = new StringBuffer("Journal des évènements\n");
executerRequeteSOAP();
}
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 = "urn:ws.rdvmedecins";
// url du service
String urlService= "http://localhost:8080/serveur-webservice-ejb-dao-jpa-hibernate/WsDaoJpaService";
// méthode du service
String methodeChoisie = "getAllClients";
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 );
// ajout des propriétés pour cette méthode
//objetSOAPHello .addProperty ("","");
//objetSOAPHello .addProperty ("nom", "Hochon");
// 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;envelope = new SoapSerializationEnvelope(SoapSerializationEnvelope.VER11);
// 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");
aE.printStackTrace ();
return;
}
// connexion au serveur
try
{
// invoquation de la méthode sur le serveur
connexionServeur.call(null, 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);
}
catch (Exception aE)
{
this.tamponEcriture .append("exception déclenchée sur méthode call\n");
aE.printStackTrace();
}
} |
Partager