AXIS2 turn WebService client

C:\360Downloads\axis2-1.6.1-bin\axis2-1.6.1\bin>wsdl2java -uri http:/ /www.****.net/webservice/smsservice.asmx?wsdl -p com.club.webservice.sms -s -o stub

Generate a SMSServiceStub.java file, and then use this file That’s it.

package com.club.webservice.sms;

import java.util.Calendar;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.club.webservice.sms.SMSServiceStub.SendSMS;
import com.club.webservice.sms.SMSServiceStub.SendSMSCovey;
import com.club.webservice.sms.SMSServiceStub.SendSMSCoveyResponse;
import com.club.webservice.sms.SMSServiceStub.SendSMSResponse;


public class SMSUtils {

private static final Logger log = LoggerFactory.getLogger(SMSUtils.class);

private static SMSUtils instance = null;

    public static SMSUtils getInstance() {
        if (instance == null) {
            instance = new SMSUtils();
        }
        return instance;
    }

public String mySendSMS(String tokenid, String content, String mobile, Calendar c, int formatid) throws Exception {
SMSServiceStub stub = new SMSServiceStub();
SendSMS send = new SendSMS();
send.setTokenID(tokenid);
send.setContent(content);
send.setMobile(mobile);
send.setScheduleDate(c);
send.setFormatID(formatid);
SendSMSResponse smsResponse = stub.sendSMS(send);
//log.info(smsResponse.getSendSMSResult());
return smsResponse.getSendSMSResult();
}

/**
* Not recommended by SMS providers
* @param tokenid
* @param xml
* @throws Exception
*/
public void mySendSMSCovey(String tokenid, String xml) throws Exception {
SMSServiceStub stub = new SMSServiceStub();
SendSMSCovey covey = new SendSMSCovey();
covey.setTokenID(tokenid);
covey.setXMLStr(xml);
SendSMSCoveyResponse coveyResponse = stub.sendSMSCovey(covey);
log.info(coveyResponse.getSendSMSCoveyResult());
}
}

Leave a Comment

Your email address will not be published.