package com.segsec.gisap.webservice; import java.util.Vector; import javax.xml.namespace.QName; import org.apache.axis.client.Call; import org.apache.axis.client.Service; import org.apache.axis.encoding.XMLType; public class LbsRescue { private String url = "http://IP地址/LbsRescue.asmx";// 提供接口的地址 private String soapaction = "http://www.***.net:7005/"; // 域名,这是在server定义的 public LbsRescue() { String City = "北京"; Service service = new Service(); try { Call call = (Call) service.createCall(); call.setTargetEndpointAddress(new java.net.URL(url)); call.getMessageContext().setUsername("ygbx");// axis中的用户名。 call.getMessageContext().setPassword("5kY3XhfxyNnHPtwrhvDycQ==");// 密码 call.setUseSOAPAction(true); call.setSOAPActionURI(soapaction + "sendList"); call.setOperationName(new QName(soapaction, "sendList")); // 设置要调用哪个方法 call.addParameter( new QName(soapaction, "companyid"), // 设置要传递的参数 org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter( new QName(soapaction, "companypwd"), // 设置要传递的参数 org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter( new QName(soapaction, "mobile"), // 设置要传递的参数 org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter( new QName(soapaction, "flag"), // 设置要传递的参数 org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.setReturnType(XMLType.XSD_STRING); // 要返回的数据类型(自定义类型) // call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);//(标准的类型) call.setUseSOAPAction(true); call.setSOAPActionURI(soapaction + "sendList"); String s = (String) call.invoke(new Object[] {"ygbx","pfAo/msenzv8lChXTPa9yw==","15910510352",1});// 调用方法并传递参数 System.out.println("注册手机:"+s); } catch (Exception ex) { ex.printStackTrace(); } } public static void main(String args[]) { LbsRescue LR = new LbsRescue(); } }