//调用部分 import java.net.URL; import javax.xml.namespace.QName; import javax.xml.rpc.ParameterMode; import javax.xml.rpc.encoding.SerializerFactory; import javax.xml.rpc.encoding.TypeMapping; import javax.xml.rpc.encoding.TypeMappingRegistry; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.encoding.XMLType; import org.apache.axis.encoding.ser.JAFDataHandlerDeserializerFactory; import org.apache.axis.encoding.ser.JAFDataHandlerSerializerFactory; import org.apache.axis.message.soAPHeaderElement; import javax.xml.soap.soAPElement; public class SendSMSObjectHB implements Runnable { public String phones = null;//13345678901 public String msg = null;// "object测试"; 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 = send2Imp("abc","123456","1216",110,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 ); } public static String send2Imp(String sname,String spwd,String scorpid, int sprdid,String sdst,String smsg) { String ret = null; try { String nameSpace = "http://tempuri.org/"; String endPoint = "http://218.56.178.100/sms/service.asmx"; Service service = new Service(); Call call = null; call = (Call) service.createCall(); call.setTargetEndpointAddress(new URL(endPoint)); call.setoperationName(new QName(nameSpace,"g_Submit")); call.addParameter(new QName(nameSpace,"sname"), XMLType.XSD_STRING,ParameterMode.IN); call.addParameter(new QName(nameSpace,"spwd"),XMLType.XSD_STRING, ParameterMode.IN); call.addParameter(new QName(nameSpace,"scorpid"),"sprdid"),"sdst"),"smsg"), ParameterMode.IN); call.setReturnType(new javax.xml.namespace.QName(nameSpace, "CSubmitState")); call.setReturnClass(CSubmitState.class); call.setUseSOAPAction(true); call.setSOAPActionURI(nameSpace + "g_Submit"); call.setProperty(org.apache.axis.AxisEngine.PROP_DOMULTIREFS, Boolean.FALSE); Object css = call.invoke(new Object[] { sname,spwd,scorpid, sprdid,sdst,smsg }); System.out.println("msgid:" + ((CSubmitState) css).getMsgiD()); System.out.println("state:" + ((CSubmitState) css).getState()); System.out.println("reserve:" + ((CSubmitState) css).getReserve()); System.out .println("msgstate:" + ((CSubmitState) css).getMsgState()); } catch (Exception e) { e.printstacktrace(); } return ret; } public static void main(String[] args) { send2Imp("ABC","15921256333","object测试"); } } ========================================================== CSubmitState 返回的对象的写法 ====================================================== package com.madhouse; public class CSubmitState implements java.io.Serializable { private int state; private java.lang.String msgiD; private java.lang.String msgState; private int reserve; public CSubmitState() { } public CSubmitState( int state, java.lang.String msgiD, java.lang.String msgState, int reserve) { this.state = state; this.msgiD = msgiD; this.msgState = msgState; this.reserve = reserve; } /** * Gets the state value for this CSubmitState. * * @return state */ public int getState() { return state; } /** * Sets the state value for this CSubmitState. * * @param state */ public void setState(int state) { this.state = state; } /** * Gets the msgiD value for this CSubmitState. * * @return msgiD */ public java.lang.String getMsgiD() { return msgiD; } /** * Sets the msgiD value for this CSubmitState. * * @param msgiD */ public void setMsgiD(java.lang.String msgiD) { this.msgiD = msgiD; } /** * Gets the msgState value for this CSubmitState. * * @return msgState */ public java.lang.String getMsgState() { return msgState; } /** * Sets the msgState value for this CSubmitState. * * @param msgState */ public void setMsgState(java.lang.String msgState) { this.msgState = msgState; } /** * Gets the reserve value for this CSubmitState. * * @return reserve */ public int getReserve() { return reserve; } /** * Sets the reserve value for this CSubmitState. * * @param reserve */ public void setReserve(int reserve) { this.reserve = reserve; } // private java.lang.Object __equalsCalc = null; // public synchronized boolean equals(java.lang.Object obj) { // if (!(obj instanceof CSubmitState)) return false; // CSubmitState other = (CSubmitState) obj; // if (obj == null) return false; // if (this == obj) return true; // if (__equalsCalc != null) { // return (__equalsCalc == obj); // } // __equalsCalc = obj; // boolean _equals; // _equals = true && // this.state == other.getState() && // ((this.msgiD==null && other.getMsgiD()==null) || // (this.msgiD!=null && // this.msgiD.equals(other.getMsgiD()))) && // ((this.msgState==null && other.getMsgState()==null) || // (this.msgState!=null && // this.msgState.equals(other.getMsgState()))) && // this.reserve == other.getReserve(); // __equalsCalc = null; // return _equals; // } // // private boolean __hashCodeCalc = false; // public synchronized int hashCode() { // if (__hashCodeCalc) { // return 0; // } // __hashCodeCalc = true; // int _hashCode = 1; // _hashCode += getState(); // if (getMsgiD() != null) { // _hashCode += getMsgiD().hashCode(); // } // if (getMsgState() != null) { // _hashCode += getMsgState().hashCode(); // } // _hashCode += getReserve(); // __hashCodeCalc = false; // return _hashCode; // } // Type Metadata private static org.apache.axis.description.TypeDesc typeDesc = new org.apache.axis.description.TypeDesc(CSubmitState.class,true); static { typeDesc.setXmlType(new javax.xml.namespace.QName("http://tempuri.org/","CSubmitState")); org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("state"); elemField.setXmlName(new javax.xml.namespace.QName("http://tempuri.org/","State")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","int")); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("msgiD"); elemField.setXmlName(new javax.xml.namespace.QName("http://tempuri.org/","MsgiD")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string")); elemField.setMinOccurs(0); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("msgState"); elemField.setXmlName(new javax.xml.namespace.QName("http://tempuri.org/","MsgState")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string")); elemField.setMinOccurs(0); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); elemField = new org.apache.axis.description.ElementDesc(); elemField.setFieldName("reserve"); elemField.setXmlName(new javax.xml.namespace.QName("http://tempuri.org/","Reserve")); elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","int")); elemField.setNillable(false); typeDesc.addFieldDesc(elemField); } /** * Return type Metadata object */ public static org.apache.axis.description.TypeDesc getTypeDesc() { return typeDesc; } /** * Get Custom Serializer */ public static org.apache.axis.encoding.Serializer getSerializer( java.lang.String mechType, java.lang.class _javaType, javax.xml.namespace.QName _xmlType) { return new org.apache.axis.encoding.ser.BeanSerializer( _javaType,_xmlType,typeDesc); } /** * Get Custom Deserializer */ public static org.apache.axis.encoding.Deserializer getDeserializer( java.lang.String mechType, javax.xml.namespace.QName _xmlType) { return new org.apache.axis.encoding.ser.BeanDeserializer( _javaType,typeDesc); } }