new BeanSerializerFactory(wsepcls, wsExamPlanQN), new BeanDeserializerFactory(wsepcls, wsExamPlanQN)); call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName(new QName(\ \
call.addParameter(\ call.addParameter(\ call.addParameter(\ call.setReturnType(searchresultqn);
ExamPlanContainer result = (ExamPlanContainer) call .invoke(new Object[] { new Long(1), new Long(0), new Long(1000) }); if (result != null) {
List list = result.getExamPlanList();
for (Iterator iter = list.iterator(); iter.hasNext();) { WsExamPlan wsExamPlan = (WsExamPlan) iter.next(); System.out.println(wsExamPlan.getName()); } }
} catch (javax.xml.rpc.ServiceException e) { e.printStackTrace();
} catch (java.net.MalformedURLException e) {
e.printStackTrace();
} catch (java.rmi.RemoteException e) { e.printStackTrace(); } }
public static void testCount() { try {
String endpoint = \ Service service = new Service(); Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint)); call.setOperationName(new QName(\ \
call.addParameter(\ call.setReturnType(XMLType.XSD_INT); Integer result = (Integer) call
.invoke(new Object[] { new Long(1) }); System.out.println(result);
} catch (javax.xml.rpc.ServiceException e) { e.printStackTrace();
} catch (java.net.MalformedURLException e) { e.printStackTrace();
} catch (java.rmi.RemoteException e) { e.printStackTrace(); } } }
第五步:get方式访问测试
http://localhost:8080/exam/services/ExamService?method=getAllowAnswerExamPlanContainer¶mter0=1¶mter1=1¶mter2=1
建webservice服务的各种框架(axis、axis2、xifre) 文章分类:Java编程
此篇文章未完成,请稍后在查看。本来是保存为草稿的,可是又编辑几次后,不知道怎么就发布了。第一次写blog,大家别拍砖。。。
最近项目用了webservice,调研了几个框架(axis、axis2、xifre),现在分别来说明下这几个框架的使用及优缺点。
1、axis。
axis是这几个建webservice服务框架中,速度最慢、配置最复杂的一个,也难怪Apache要放弃它了。
首先在eclipse中建立一个web工程,取名为WebService-axis,建一个包test,在此包下建一个类Hello,Hello代码如下: Java代码
1. public class Hello {
2. public String sayHello(String name) { 3. return \
4. } 5. }
public class Hello {
右键点击这个类,“Web Services”——>“Create Web service”,出现如图:
然后点N下“Next”(其中有步要先点“start server”,要不“next”为灰不可用)。
完成之后,eclipse便帮我们将服务端和客户端都生成了,我们来看看都生成了哪些代码。 首先,服务端目录结构:
在集成Spring + Axis 的环境下webservice的发布和部署 2008-03-04 18:22 开发中遇到两个难点:
1. 在集成Spring + Axis 的环境下webservice的发布和部署; 2. 文件上传和下载的commons-fileupload-1.2的使用。 下面分别谈这两个问题.
一. 在集成Spring + Axis 的环境下webservice的发布和部署 1.1 DEMO文件样例 1.1.1 项目结构图: