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
|
public static void main(String[] args) throws Exception
{
XmlRpcClient client = new XmlRpcClient("mon url", 8443);
//Création de l'entête
Hashtable entete = new Hashtable();
entete.put("Login", "loginTest");
entete.put("Password", "passwordTest");
entete.put("TransmitterId","4000");
entete.put("TerminalId", "@locale");
entete.put("TransactionId", new Integer(1001));
//
Vector listeCarte = new Vector();
//
Hashtable carte = new Hashtable();
carte.put("RandomNum", "1234567890123456789");
carte.put("PinCode", "1111");
//
listeCarte.add(carte);
//Création du vecteur de paramètre
Vector params = new Vector();
params.add(entete);
params.add(listeCarte);
//Appel au serveur XML-RPC
Object [] response1= (Object [])client.execute("Ppp.maMethode", params);
if (response1!=null) {
//First element is always there, this is the header in a HashMap
HashMap header = (HashMap)response1[0];
System.out.println("header = "+ header);
System.out.println("Response = "+ header.get("RequestResponse"));
System.out.println("ResponseWordings = "+ header.get("ResponseWording"));
//
if(response1.length>1) {
//If present, second element of the vector is another vector of hashtables
Object [] cards = (Object []) response1[1];
for (int i=0; i<cards.length;i++) {
HashMap currentCard = (HashMap )cards[i];
System.out.println("Card response #"+i);
//
System.out.println(" RandomNum="+currentCard.get("RandomNum"));
System.out.println(" CardResponse="+currentCard.get("CardResponse"));
System.out.println(" CardResponseWording="+currentCard.get("CardResponseWording"));
System.out.println(" CardBalance="+currentCard.get("CardBalance"));
}
}
} |
Partager