JAVA调用webservice(不自动生成客户端)

AXIS调用方法:

   String endpoint = "http://****?wsdl";
   org.apache.axis.client.Service service = new
   org.apache.axis.client.Service();
   org.apache.axis.client.Call call = (org.apache.axis.client.Call)
   service.createCall();
   call.setTargetEndpointAddress(endpoint);
   call.setOperationName(new
   QName("***","GetPath"));//
   call.addParameter("paramXml", org.apache.axis.encoding.XMLType.XSD_STRING,
   javax.xml.rpc.ParameterMode.IN);
   call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
   String temp ="111";
   String result = (String) call.invoke(new Object[] { temp });
   System.out.println("result is " + result);


AXIS2调用方法:

   RPCServiceClient serviceClient = new RPCServiceClient();

   Options options =serviceClient.getOptions();

   EndpointReference targetEPR = new EndpointReference(url);

   options.setTo( targetEPR );

   options.setTimeOutInMilliSeconds( 10000 );

   String method = "GetPath";//webservice的方法名

   String xml = "111";

   Object[] param = new Object[] {xml};

   QName opName = new QName( "***", method );

   Class[] returnTypes = new Class[]{String.class};

   Object[] results =serviceClient.invokeBlocking( opName, param, returnTypes );

  System.out.println(results[0].toString());


CXF调用方法(依赖jdk1.6,与老版本spring冲突):

    JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();

    org.apache.cxf.endpoint.Clientclient = dcf.createClient(url);

    Object[] param = null;

    String method = "GetPath";// webservice的方法名

    String xml = "111";

    param = new Object[] { xml };

    Object[] obj = client.invoke(method,param);

   System.out.println(obj[0].toString());


xfire调用方法:

    Client client = null;

    client = new Client(new URL(wsUrl));

    Object[] param = null;

    String method = "GetPath";// webservice的方法名

    String xml = "111";

    param = new Object[] { xml };

    Object[] obj = client.invoke(method, param);

   System.out.println(obj[0].toString());




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值