helios创建Web Service服务
2013-11-15 16:09
190 查看
写好一个service服务后,点击右键,出现Web Service。。。如下图:
下面的步骤,除了启动server tomcat 服务外,其它都点击next就行了。
web hello service源代码:
client:即调用web service的服务。
参考资料:
http://blog.csdn.net/xw13106209/article/details/7049614
下面的步骤,除了启动server tomcat 服务外,其它都点击next就行了。
web hello service源代码:
package com.test.service; public class HelloService { public String sayHelloNew() { return "hello"; } public String sayHelloToPersonNew(String name) { if (name == null) { name = "nobody"; } return "hello," + name; } public void updateData(String data) { System.out.println(data + " 已更新。"); } }
client:即调用web service的服务。
package com.test.client; import javax.xml.namespace.QName; 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 CalculateClient { public void invokeHelloService() throws AxisFault { // 使用RPC方式调用WebService RPCServiceClient serviceClient = new RPCServiceClient(); Options options = serviceClient.getOptions(); // 指定调用WebService的URL EndpointReference targetEPR = new EndpointReference( "http://localhost:8080/CalculateService/services/HelloService"); options.setTo(targetEPR); // 指定要调用的计算机器中的方法及WSDL文件的命名空间:edu.sjtu.webservice。 QName opAddEntry = new QName("http://service.test.com", "sayHelloToPersonNew");// 加法 // 指定plus方法的参数值为两个,分别是加数和被加数 Object[] opAddEntryArgs = new Object[] { "CSDN" }; // 指定plus方法返回值的数据类型的Class对象 Class[] classes = new Class[] { String.class }; // 调用plus方法并输出该方法的返回值 System.out.println(serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[0]); } public void invokeCalculateService() throws AxisFault { // 使用RPC方式调用WebService RPCServiceClient serviceClient = new RPCServiceClient(); Options options = serviceClient.getOptions(); // 指定调用WebService的URL EndpointReference targetEPR = new EndpointReference( "http://localhost:8080/CalculateService/services/CalculateService"); options.setTo(targetEPR); // 指定要调用的计算机器中的方法及WSDL文件的命名空间:edu.sjtu.webservice。 QName opAddEntry = new QName("http://service.test.com", "plus");// 加法 // 指定plus方法的参数值为两个,分别是加数和被加数 Object[] opAddEntryArgs = new Object[] { 1, 5 }; // 指定plus方法返回值的数据类型的Class对象 Class[] classes = new Class[] { Float.class }; // 调用plus方法并输出该方法的返回值 System.out.println(serviceClient.invokeBlocking(opAddEntry, opAddEntryArgs, classes)[0]); } public static void main(String args[]) throws AxisFault { CalculateClient client = new CalculateClient(); client.invokeCalculateService(); client.invokeHelloService(); } }
2013-11-15 15:24:50 org.apache.axis2.deployment.ModuleDeployer deploy 信息: Deploying module: addressing-1.6.2 - file:/E:/repository/org/apache/axis2/axis2/1.6.2/axis2-1.6.2.jar 6.0 2013-11-15 15:24:51 org.apache.axis2.deployment.ModuleDeployer deploy 信息: Deploying module: addressing-1.6.2 - file:/E:/repository/org/apache/axis2/axis2/1.6.2/axis2-1.6.2.jar hello,CSDN
参考资料:
http://blog.csdn.net/xw13106209/article/details/7049614
相关文章推荐
- 演练:在 Visual Web Developer 中创建和使用 ASP.NET Web 服务------Web Service
- 使用Axis创建Web Service服务
- Web服务入门之一:通过Xfire创建本地Web Service并调用
- 王晓东原创:C# 简易IDE开发工具-快速创建Windows和Web程序及Web Service服务!
- 主题:使用Axis创建Web Service服务
- 使用Axis创建Web Service服务
- 使用Axis创建Web Service服务
- Sql Server分析服务与多维数据库的学习——CUBE创建
- Web服务(Web Service)相关概念
- C# 创建Windows服务。服务功能:定时操作数据库
- 怎样创建.NET Web Service
- Wcf Ria Services学习笔记(二):创建一个简单WCF RIA Service服务
- Android创建Service后台常驻服务并使用Broadcast通信
- 创建动态代理服务
- 云服务虚拟机创建(备忘一)
- 通过Dockerfile创建Mysql服务的Centos镜像
- C# 创建window服务
- 创建SvcHost.exe调用的服务原理与实践
- 创建SvcHost.exe调用的服务原理与实践收藏
- 服务级后门自己做——创建服务