package com.wnwn.ws;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import javax.xml.ws.Holder;
public class caluc {
//简单对象
public int add(int a,int b) {
return a+b;
}
public int sub(int a,int b) {
return a-b;
}
//list泛型
public List<String> rtnMethod() {
List<String> testList = new ArrayList<String>();
testList.add("abc");
testList.add("efg");
testList.add("111");
return testList;
}
//发送javabean对象
public List<Person> getPerson() {
List<Person> testList = new ArrayList<Person>();
Person p = new Person();
p.setName("abc");
p.setAge(31);
p.setGender("female");
testList.add(p);
p = new Person();
p.setName("def");
p.setAge(33);
p.setGender("male");
testList.add(p);
p = new Person();
p.setName("aaa");
p.setAge(26);
p.setGender("female");
testList.add(p);
return testList;
}
//接收上传的图像数据,并保存成文件
public void echoData(Holder<byte[]> data) {
OutputStream os = null;
ByteArrayInputStream bin = null;
try {
bin = new ByteArrayInputStream(data.value);
if (data.value != null)
os = new FileOutputStream("c:/echoData.jpg");
byte[] bytes = new byte[1024];
int c;
while ((c = bin.read(bytes)) != -1) {
os.write(bytes, 0, c);
}
os.close();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (os != null) {
os.close();
os = null;
}
} catch (Exception e) {
}
try {
if (bin != null) {
bin.close();
bin = null;
}
} catch (Exception e) {
}
}
}
//上传更复杂的数据
public void uploadCustomerByName(Customer customer) {
InputStream is = null;
OutputStream os = null;
try {
System.out.println("customer====" + customer.getId() + " " + customer.getName());
System.out.println("generate jpg......");
is = customer.getMyPhoto().getInputStream();
os = new FileOutputStream("c:/customer.jpg");
byte[] bytes = new byte[1024];
int c;
while ((c = is.read(bytes)) != -1) {
os.write(bytes, 0, c);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (os != null) {
os.close();
os = null;
}
} catch (Exception e) {
}
try {
if (is != null) {
is.close();
is = null;
}
} catch (Exception e) {
}
}
}
//=-------
}
没有合适的资源?快使用搜索试试~ 我知道了~
jax-ws_webservice服务端程序演示

共51个文件
class:16个
java:16个
prefs:4个


温馨提示
调试环境:mycelipse10+tomcat7 包含调用简单数据类型,List<String>类型,下载javabean对象,上传图像文件,上传javabean复杂数据对象等5个代码例子。 调试环境的配置,网上很多文章都写了。
资源推荐
资源详情
资源评论





























收起资源包目录











































































共 51 条
- 1
资源评论

- ws041700992013-07-23还好吧,有一定的借鉴作用
- maoriking2014-02-11并不是我想要的那种。。。我想要的传参是List的,而不是返回是List的
- lfl111112014-07-09过的去,不是想要的,稍微简单了点
- hu7502013-01-28还行。。就是简单点
- NinjaPanda2013-06-02内容不错,入门级

dinyylii
- 粉丝: 2
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- ansys高级非线性分析2单元技术.ppt
- Ansys热分析教程_part4_非线形分析的一些特殊考虑.ppt
- Ansys热分析教程_part5_瞬态分析.ppt
- Ansys热分析教程_part8_热辐射分析.ppt
- Ansys热分析教程_part10_耦合场分析.ppt
- ansys实例-15000吨甲板驳船结构强度计算分析.ppt
- APS产品介绍(上).ppt
- AutoCAD教程全集.ppt
- BPM软件应用价值分析和实施案例分析.ppt
- Autodesk Inventor建模基础教程.pptx
- B-Suite供应链管理(SCM)产品规划.ppt
- CAE基础培训.ppt
- CAPP连载2:CAPP概述.ppt
- CAPP连载1:计算机辅助工艺设计(CAPP)基础.part1.ppt
- CATIA数据的集成管理.ppt
- CAPP支撑环境.ppt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
