JAVA调用web service(axis方式)

import javax.xml.namespace.QName;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;

public class Test {

public static void main(String[] args) {
   //testAddCustomer();
   //testValidateLogin();
   testGetMessageInfo();
}

public static void testAddCustomer(){
   try {
    String endpoint = "http://localhost:8080/ehomeSer/services/WebServiceCenter?wsdl";
    Service service = new Service();
    Call call = (Call) service.createCall();
    call.setTargetEndpointAddress(endpoint);
    call.setOperationName(new QName("http://webservice.ehome.qinan.com","addCustomer"));
    call.addParameter("name", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
    call.addParameter("key_code", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
    call.addParameter("idcard", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
    call.addParameter("pwd", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
    call.addParameter("tel", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
    call.addParameter("address", org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN);
    call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
    call.setUseSOAPAction(true);
    call.setSOAPActionURI("http://localhost:8080/ehomeSer");
    String result = (String)call.invoke(new Object[]{"张三","KEY123","46368119900125794X","123456","0731-1231321","长沙市"});
    System.out.println("addCustomer result is "+result);
   }
   catch (Exception e) {
    System.err.println(e.toString());
   }
}

}
 

 

深圳人才网 深圳招聘网 深圳人才招聘网 深圳人才大市场 

企业、个人免费注册,获取想要的 深圳 软件工程师招聘信息 月薪最低3000-8000,更有高端猎头职位! 

www.szrcwz.com                                                                                                                                           

                  Google 提供的广告

posted @ 2010-09-26 17:22  栈长  阅读(87)  评论(0编辑  收藏  举报