解决方案 »
- java如何调用批处理还原MSSQL,批处理怎么写
- 在Java开发中什么样的功能或项目会用到并发程序设计?
- jdbc 链接SQL2005 出错!
- jQuery 学习技巧
- hibernate到底有没有用、?
- 不明白struts有什么好的,他能做的servlet都能做呀
- 我是一个很菜的菜鸟!请问一下,为什么在JBuilder里输入字符时,总是在错位,好象看不清楚一样,是怎么回事?
- 如何访问其他的机器的问题
- 一个关于struts的二级分类的显示问题,高分求救!
- Hibernate报错Could not parse mapping document from resource cn/jbit/pojo/XX
- 请帮我推荐2本学习luncene的书
- 求助,导出数据库二进制内容为本地图片文件显示红叉??
public class Client {
// public static void main(String[] args) throws RemoteException, ServiceException, MalformedURLException {
/* **************** 调用方法1 *********************** */
RPCServiceClient rpcClient = new RPCServiceClient();
Options opt = new Options();
opt.setTo(new EndpointReference("http://localhost:8080/axis2/services/Hello")); //服务地址
opt.setAction("urn:hw"); //方法
rpcClient.setOptions(opt);
OMElement element = rpcClient.invokeBlocking(new QName("http://com", "hw"), new Object[]{null}); //null表示没有参数传递 Iterator values = element.getChildrenWithName(new QName("http://com", "return")); //return表示有返回值
while (values.hasNext()) { //遍历出获取的数据
OMElement omElement = (OMElement) values.next();
System.out.println(omElement.getText());
} /* **************** 调用方法2 *********************** */
String method = "hw";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL("http://localhost:8080/axis2/services/Hello"));
call.setOperationName(new QName("http://com/", method));
call.setUseSOAPAction(true);
call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
call.setSOAPActionURI("http://com/GetServerList");
String k = (String)call.invoke(new Object[]{}); //因为返回值是String类型,所以这里调用的返回值也是String类型
System.out.println(">>> "+k); //返回值输出 }
}