String url = "http://192.168.0.90:8088/wsServerExample"; String namespace = "http://webserver.server.com/"; try { org.apache.axis.client.Service service = new org.apache.axis.client.Service(); Call call = (Call) service.createCall(); // 设置调用服务地址 call.setTargetEndpointAddress(new java.net.URL(url)); // 此处一定要配置wsdl的namespace参数 call.setOperationName(new QName(namespace, "queryObjectOut")); // 此处需要配置传入参数类型与参数名称,如果未设置jax-ws则无法接受参数,会认为传入的参数为null //这里的参数名字必须为arg0,否则接受不到参数 call.addParameter("arg0",org.apache.axis.encoding.XMLType.XSD_STRING,javax.xml.rpc.ParameterMode.IN); call.addParameter("arg1", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter("arg2", org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN); call.addParameter("arg3", 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(url); String result = (String) call .invoke(new Object[] { TransNo, Inxml,"11","21321" }); System.out.println(result); } catch (Exception e) { e.printStackTrace(); }
时间: 2024-11-10 05:40:37