import org.apache.axis2无法导入

瑾丫丫 2014-07-02 06:08:03
package edu.bjut.webservice.test;

import javax.xml.namespace.QName;

import org.apache.axis2.rpc.client.RPCServiceClient;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.rpc.client.RPCServiceClient;

public class CalculateServiceTest {

/**
* @param args
* @throws AxisFault
*/
public static void main(String[] args) throws AxisFault {
// TODO Auto-generated method stub

// 使用RPC方式调用WebService
RPCServiceClient serviceClient = new RPCServiceClient();
Options options = serviceClient.getOptions();
// 指定调用WebService的URL
EndpointReference targetEPR = new EndpointReference(
"http://localhost:8080/WebServiceTest1/services/CalculateService");
options.setTo(targetEPR);

// 指定要调用的计算机器中的方法及WSDL文件的命名空间:edu.sjtu.webservice。
QName opAddEntry = new QName("http://webservice.sjtu.edu","plus");//加法
QName opAddEntryminus = new QName("http://webservice.sjtu.edu","minus");//减法
QName opAddEntrymultiply = new QName("http://webservice.sjtu.edu","multiply");//乘法
QName opAddEntrydivide = new QName("http://webservice.sjtu.edu","divide");//除法
// 指定plus方法的参数值为两个,分别是加数和被加数
Object[] opAddEntryArgs = new Object[] { 1,2 };
// 指定plus方法返回值的数据类型的Class对象
Class[] classes = new Class[] { float.class };
// 调用plus方法并输出该方法的返回值
System.out.println(serviceClient.invokeBlocking(opAddEntry,opAddEntryArgs, classes)[0]);
System.out.println(serviceClient.invokeBlocking(opAddEntryminus,opAddEntryArgs, classes)[0]);
System.out.println(serviceClient.invokeBlocking(opAddEntrymultiply,opAddEntryArgs, classes)[0]);
System.out.println(serviceClient.invokeBlocking(opAddEntrydivide,opAddEntryArgs, classes)[0]);

}
}
...全文
814 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
小鸟123 2015-03-30
  • 打赏
  • 举报
回复
遇到了相同的问题,求告知啊!
波儸密 2014-12-17
  • 打赏
  • 举报
回复
点击第一个红叉叉 ,提示什么错误?
z931284151 2014-12-17
  • 打赏
  • 举报
回复
同问啊~~??
cary_lg 2014-09-24
  • 打赏
  • 举报
回复
怎么解决的?

24,923

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Apache
社区管理员
  • Apache
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧