C:\360Downloads\axis2-1.6.1-bin\axis2-1.6.1\binwsdl2java -uri http://www.****.net/webservice/smsservice.asmx?wsdl -p com.club.webservice.sms -s -o stub 生成一个SMSServiceStub.java的文件,然后用这个文件就可以了。 package
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
生成一个SMSServiceStub.java的文件,然后用这个文件就可以了。
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(); } /** * 短信供应商不建议使用 * @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()); } }