Alo galera estou estou querendo fazer uma aplicação para envio de sms
e estou a usar um exemplo que peguei aqui no forum no link asseguir http://www.guj.com.br/java/131103-smpp
e aquando executo da-me o seguinte erro:
log4j:WARN No appenders could be found for logger (org.jsmpp.session.SMPPSession).
log4j:WARN Please initialize the log4j system properly.
Failed connect and bind to host
java.io.IOException: Receive negative bind response: Negative response 0000000d found
at org.jsmpp.session.SMPPSession.connectAndBind(SMPPSession.java:246)
at org.jsmpp.session.SMPPSession.connectAndBind(SMPPSession.java:200)
at smsito.SimpleSubmitExample.main(SimpleSubmitExample.java:34)
IO error occur
java.net.SocketException: Socket closed
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:99)
at java.net.SocketOutputStream.write(SocketOutputStream.java:124)
at org.jsmpp.DefaultPDUSender.writeAndFlush(DefaultPDUSender.java:419)
at org.jsmpp.DefaultPDUSender.sendSubmitSm(DefaultPDUSender.java:203)
at org.jsmpp.SynchronizedPDUSender.sendSubmitSm(SynchronizedPDUSender.java:192)
at org.jsmpp.session.SubmitSmCommandTask.executeTask(SubmitSmCommandTask.java:86)
at org.jsmpp.session.AbstractSession.executeSendCommand(AbstractSession.java:248)
at org.jsmpp.session.SMPPSession.submitShortMessage(SMPPSession.java:320)
at smsito.SimpleSubmitExample.main(SimpleSubmitExample.java:41)
o codigo que estou a testar eh o seguinte:
package smsito;
import java.io.IOException;
import java.util.Date;
import org.jsmpp.InvalidResponseException;
import org.jsmpp.PDUException;
import org.jsmpp.bean.Alphabet;
import org.jsmpp.bean.BindType;
import org.jsmpp.bean.ESMClass;
import org.jsmpp.bean.GeneralDataCoding;
import org.jsmpp.bean.MessageClass;
import org.jsmpp.bean.NumberingPlanIndicator;
import org.jsmpp.bean.RegisteredDelivery;
import org.jsmpp.bean.SMSCDeliveryReceipt;
import org.jsmpp.bean.TypeOfNumber;
import org.jsmpp.extra.NegativeResponseException;
import org.jsmpp.extra.ResponseTimeoutException;
import org.jsmpp.session.BindParameter;
import org.jsmpp.session.SMPPSession;
import org.jsmpp.util.AbsoluteTimeFormatter;
import org.jsmpp.util.TimeFormatter;
/**
* @author uudashr
*
*/
public class SimpleSubmitExample {
private static TimeFormatter timeFormatter = new AbsoluteTimeFormatter();;
public static void main(String[] args) {
SMPPSession session = new SMPPSession();
try {
session.connectAndBind("192.168.10.248", 1817, new BindParameter(BindType.BIND_TX, "teste", "teste", "cp", TypeOfNumber.UNKNOWN, NumberingPlanIndicator.UNKNOWN, null));
} catch (IOException e) {
System.err.println("Failed connect and bind to host");
e.printStackTrace();
}
//o numero 284709018 eh o Nr de celular p teste
try {
String messageId = session.submitShortMessage("CMT", TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.UNKNOWN, "1616", TypeOfNumber.INTERNATIONAL, NumberingPlanIndicator.UNKNOWN, "284709018", new ESMClass(), (byte)0, (byte)1, timeFormatter.format(new Date()), null, new RegisteredDelivery(SMSCDeliveryReceipt.DEFAULT), (byte)0, new GeneralDataCoding(false, false, MessageClass.CLASS1, Alphabet.ALPHA_DEFAULT), (byte)0, "jSMPP simplify SMPP on Java platform".getBytes());
System.out.println("Message submitted, message_id is " + messageId);
} catch (PDUException e) {
// Invalid PDU parameter
System.err.println("Invalid PDU parameter");
e.printStackTrace();
} catch (ResponseTimeoutException e) {
// Response timeout
System.err.println("Response timeout");
e.printStackTrace();
} catch (InvalidResponseException e) {
// Invalid response
System.err.println("Receive invalid respose");
e.printStackTrace();
} catch (NegativeResponseException e) {
// Receiving negative response (non-zero command_status)
System.err.println("Receive negative response");
e.printStackTrace();
} catch (IOException e) {
System.err.println("IO error occur");
e.printStackTrace();
}
session.unbindAndClose();
}
}