Search in sources :

Example 6 with SMSMessage

use of org.apache.axis2.transport.sms.SMSMessage in project wso2-axis2-transports by wso2.

the class GSMImplManager method sendSMS.

public void sendSMS(SMSMessage sm) throws AxisFault {
    if (service == null && !serviceRepo.gatewayInUse(gsmTransportOutDetails.getGatewayId())) {
        // Operating in the Out Only mode
        service = new Service();
        gateway = new SerialModemGateway(gsmTransportOutDetails.getGatewayId(), gsmTransportOutDetails.getComPort(), gsmTransportOutDetails.getBaudRate(), gsmTransportOutDetails.getManufacturer(), gsmTransportOutDetails.getModel());
        // Set the modem protocol to PDU (alternative is TEXT). PDU is the default, anyway...
        gateway.setProtocol(AGateway.Protocols.PDU);
        // Do we want the Gateway to be used for Outbound messages?
        gateway.setOutbound(true);
        // Let SMSLib know which is the SIM PIN.
        gateway.setSimPin("0000");
        try {
            // Add the Gateway to the Service object.
            this.service.addGateway(gateway);
            // Similarly, you may define as many Gateway objects, representing
            // various GSM modems, add them in the Service object and control all of them.
            // Start! (i.e. connect to all defined Gateways)
            this.service.startService();
        } catch (Exception e) {
            throw new AxisFault(e.getMessage(), e);
        }
    } else if (serviceRepo.gatewayInUse(gsmTransportOutDetails.getGatewayId())) {
        service = serviceRepo.getService(gsmTransportOutDetails.getGatewayId());
    }
    OutboundMessage msg = new OutboundMessage(sm.getReceiver(), sm.getContent());
    try {
        // a blocking call.This will be blocked untill the message is sent.
        // normal rate is about 6msgs per minute
        service.sendMessage(msg);
    } catch (Exception e) {
        throw new AxisFault(e.getMessage(), e);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) SerialModemGateway(org.smslib.modem.SerialModemGateway)

Example 7 with SMSMessage

use of org.apache.axis2.transport.sms.SMSMessage in project wso2-axis2-transports by wso2.

the class SMPPDispatcher method dispatch.

void dispatch(String source, String receiver, String message, Map<String, Object> properties) throws AxisFault {
    synchronized (this) {
        smsMessage = new SMSMessage(source, receiver, message, SMSMessage.IN_MESSAGE);
        smsMessage.getProperties().putAll(properties);
    }
    manager.dispatchToAxis2(smsMessage);
}
Also used : SMSMessage(org.apache.axis2.transport.sms.SMSMessage)

Aggregations

AxisFault (org.apache.axis2.AxisFault)5 MessageContext (org.apache.axis2.context.MessageContext)2 SMSMessage (org.apache.axis2.transport.sms.SMSMessage)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 QName (javax.xml.namespace.QName)1 SOAPEnvelope (org.apache.axiom.soap.SOAPEnvelope)1 EndpointReference (org.apache.axis2.addressing.EndpointReference)1 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)1 InvalidResponseException (org.jsmpp.InvalidResponseException)1 PDUException (org.jsmpp.PDUException)1 NegativeResponseException (org.jsmpp.extra.NegativeResponseException)1 ResponseTimeoutException (org.jsmpp.extra.ResponseTimeoutException)1 BindParameter (org.jsmpp.session.BindParameter)1 SMPPSession (org.jsmpp.session.SMPPSession)1 SerialModemGateway (org.smslib.modem.SerialModemGateway)1