import java.net.URL; import javax.xml.namespace.QName; import javax.xml.rpc.ParameterMode; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.encoding.XMLType; import org.apache.axis.message.soAPHeaderElement; import javax.xml.soap.soAPElement; public class SendSMSZOP implements Runnable { public String phones = null;//adfbcc public String msg = null;//"测试"; public int T_count=0; public int tname=0; public void run() { // System.out.println("[TN:"+tname+"] "+T_count); long s=System.currentTimeMillis(); String r = send2ZOP(phones,msg); long e = System.currentTimeMillis(); String time =(e-s)/1000==0?(e-s)+"毫秒":(e-s)/1000+"秒"+(e-s)%1000+"毫秒"; System.out.println("[TN:"+ tname+"] P:"+phones+" ST->"+time+",R->"+r ); // System.out.println("ST->"+time+",R->"+r ); } private String send2ZOP(String phones,String msg) { String ret=null; try { String Username = "dkfj"; String Password = "123456"; String nameSpace = "http://tempuri.org/"; String endPoint = "http://1.6.5.1/friend_ws/Ses.asmx"; Service service = new Service(); Call call = null; call = (Call) service.createCall(); call.setTargetEndpointAddress(new URL(endPoint)); call.setoperationName(new QName(nameSpace,"SendMsg")); call.addParameter(new QName(nameSpace,"RNos"),XMLType.XSD_STRING, ParameterMode.IN); call.addParameter(new QName(nameSpace,"Msg"), ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); call.setUseSOAPAction(true); call.setSOAPActionURI("http://tempuri.org/SendMsg"); SOAPHeaderElement element = new SOAPHeaderElement(new QName( nameSpace,"ValidHeader")); SOAPElement se = element.addChildElement("Username"); se.addTextNode(Username); se = element.addChildElement("Password"); se.addTextNode(Password); call.addHeader(element); ret = (String) call.invoke(new Object[] { phones,msg }); // System.out.println(ret); } catch (Exception e) { e.printstacktrace(); } return ret; } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。