First Commit - Source Code from Reply
This commit is contained in:
95
dbcmnpsrc/FE/mnpdev/TestInteroperatore/src/test/Sender.java
Normal file
95
dbcmnpsrc/FE/mnpdev/TestInteroperatore/src/test/Sender.java
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Created on Mar 30, 2005
|
||||
*
|
||||
* MNP [project testopiv]
|
||||
* Copyright (c) 2005
|
||||
*
|
||||
* @author Giovanni Amici
|
||||
* @version 1.0
|
||||
*/
|
||||
package test;
|
||||
|
||||
/**
|
||||
* @author Giovanni
|
||||
*
|
||||
* Window - Preferences - Java - Code Style - Code Templates
|
||||
*/
|
||||
|
||||
import java.io.RandomAccessFile;
|
||||
|
||||
public class Sender {
|
||||
|
||||
public static final String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><LISTA_MNP_RECORD xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"MNP.xsd\"><FILENAME>" +
|
||||
"<MITTENTE>TIMG</MITTENTE>" +
|
||||
"<DATA>2005-06-25</DATA>" +
|
||||
"<ORA>14:30:00</ORA>" +
|
||||
"<DESTINATARIO>OPIV</DESTINATARIO>" +
|
||||
"<ID_FILE>00001</ID_FILE>" +
|
||||
"</FILENAME>" +
|
||||
"<ATTIVAZIONE><TIPO_MESSAGGIO>1</TIPO_MESSAGGIO><CODICE_OPERATORE_RECIPIENT>TIMG</CODICE_OPERATORE_RECIPIENT><CODICE_OPERATORE_DONATING>OPIV</CODICE_OPERATORE_DONATING><CODICE_RICHIESTA_RECIPIENT>000000000000000001</CODICE_RICHIESTA_RECIPIENT><MSISDN>883280000001</MSISDN><ICCID_SERIAL_NUMBER>0000000000000000001</ICCID_SERIAL_NUMBER><CODICE_FISCALE_PARTITA_IVA>SRTMCC75C52A345Q</CODICE_FISCALE_PARTITA_IVA><CODICE_PRE_POST_PAGATO>PRP</CODICE_PRE_POST_PAGATO><CODICE_ANALOGICO_DIGITALE>D</CODICE_ANALOGICO_DIGITALE><DATA_CUT_OVER>2100-01-01</DATA_CUT_OVER><NOME_CLIENTE>ANTONELLA</NOME_CLIENTE><COGNOME_CLIENTE>AMICI</COGNOME_CLIENTE><TIPO_DOCUMENTO>PA</TIPO_DOCUMENTO><NUMERO_DOCUMENTO>AQ5633392Z</NUMERO_DOCUMENTO><IMSI>000000000000001</IMSI></ATTIVAZIONE>" +
|
||||
"</LISTA_MNP_RECORD>";
|
||||
|
||||
public Sender() {
|
||||
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
try {
|
||||
System.out.println("Inizio test invio..nuovo");
|
||||
if (args.length > 0) {
|
||||
sendFile(args[0]);
|
||||
} else {
|
||||
simpleSend();
|
||||
}
|
||||
System.out.println("Test invio completato con successo!!");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Errore test invio:");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void simpleSend() throws Exception {
|
||||
test.XMLSender.sendXML(xml, "1", "TIMG20050330122748OPIV00001", "OPIV");
|
||||
}
|
||||
|
||||
public static void sendFile(String fileName) throws Exception {
|
||||
RandomAccessFile in = null;
|
||||
try {
|
||||
|
||||
in = new RandomAccessFile(fileName, "r");
|
||||
long len = in.length();
|
||||
byte[] arr = new byte[(int) len];
|
||||
in.readFully(arr);
|
||||
|
||||
String xml = new String(arr).trim();
|
||||
System.out.println("I:" + fileName.lastIndexOf('/') + " F:" + fileName.lastIndexOf('.'));
|
||||
String name = fileName.substring(fileName.lastIndexOf('/') + 1, fileName.lastIndexOf('.'));
|
||||
String cod_olo = name.substring(18, 22);
|
||||
|
||||
System.out.println("***********************************");
|
||||
System.out.println("Sending:");
|
||||
|
||||
System.out.println("XML: <" + xml + ">");
|
||||
System.out.println("TYPE: <1>");
|
||||
System.out.println("NAME: <" + name + ">");
|
||||
System.out.println("OLO: <" + cod_olo + ">");
|
||||
|
||||
test.XMLSender.sendXML(xml, "1", name, cod_olo);
|
||||
System.out.println("Sending.. END");
|
||||
System.out.println("***********************************");
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Exception:");
|
||||
ex.printStackTrace();
|
||||
|
||||
throw ex;
|
||||
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) in.close();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user