学习Java6(一) WebServices (6)传递List(变通方法实现)

本文介绍了一个简单的Java程序,用于测试对象及其属性是否能正确传递。通过创建包含列表和基本属性的用户信息对象,并通过WebService进行调用,验证了对象及列表属性能够成功返回。
UserInfo
 1  import  java.util.ArrayList;
 2 
 3  public class UserInfo {
 4     private ArrayList list;
 5     
 6     private int id;
 7 
 8     private String name;
 9 
10     public int getId() {
11         return id;
12     }
13 
14     public void setId(int id) {
15         this.id = id;
16     }
17 
18     public String getName() {
19         return name;
20     }
21 
22     public void setName(String name) {
23         this.name = name;
24     }
25 
26     public ArrayList getList() {
27         return list;
28     }
29 
30     public void setList(ArrayList list) {
31         this.list = list;
32     }
33 }
34 

GetObject
 1 
 2 
 3  import java.util.ArrayList;
 4 import javax.jws.WebMethod;
 5 import javax.jws.WebService;
 6 import javax.jws.soap.SOAPBinding;
 7 
 8 @WebService(targetNamespace = "http://jdk.study.hermit.org/testobject")
 9 @SOAPBinding(style = SOAPBinding.Style.RPC)
10 public class GetObject {
11     @WebMethod
12     public UserInfo getUserInfo(String name) {
13         UserInfo user = new UserInfo();
14         ArrayList<String> list =new ArrayList<String>();
15         list.add("123");
16         list.add("456");
17         list.add("789");
18         user.setList(list);
19         user.setId(1);
20         user.setName(name);
21         return user;
22     }
23 
24 }


TestObject
 1  package  test;
 2 
 3  import static org.junit.Assert.*;
 4 import org.hermit.study.jdk.testobject.GetObject;
 5 import org.hermit.study.jdk.testobject.GetObjectService;
 6 import org.hermit.study.jdk.testobject.UserInfo;
 7 import org.junit.Test;
 8 
 9 public class TestObject {
10     @Test
11     public void getObject() {
12         GetObjectService service = new GetObjectService();
13         GetObject obj = service.getGetObjectPort();
14         UserInfo user = obj.getUserInfo("hermit");
15         assertNotNull(user.getId());
16         assertNotNull(user.getList());
17         assertEquals(user.getList().size(),3);
18         assertEquals(user.getList().get(0),"123");
19         assertEquals(user.getList().get(1),"456");
20         assertEquals(user.getList().get(2),"789");
21         assertEquals("hermit", user.getName());
22     }
23 }

测试通过
可见对象内的list是可以传递过来的。。。。。。。。。 96944.html

交口称赞 2007-01-31 14:13 发表评论
2025-10-21 11:23:20 [WebContainer : [yWX*235][]-D200116823-171-T:DFT-d0a9371d-c291-4ac5-84c9-5304253de252] ERROR ExceptionHandler:243 - Exception when request uri:/services/workorderFullsetService/getWorkorderFullsetListByPage/page/30/1 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property 'orderTypeArray'. It was either not specified and/or could not be found for the javaType ([Ljava.lang.String;) : jdbcType (null) combination. ### Cause: java.lang.IllegalStateException: Type handler was null on parameter mapping for property 'orderTypeArray'. It was either not specified and/or could not be found for the javaType ([Ljava.lang.String;) : jdbcType (null) combination. at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:97) ~[mybatis-spring-2.1.2.jar:2.1.2] at org.mybatis.spring.SqlSession*****#*#*****Session*****#*#*****qlSession*****#*#*****[mybatis-spring-2.1.2.jar:2.1.2] at com.sun.proxy.$Proxy249.selectList(Unknown Source) ~[?:?] at org.mybatis.spring.SqlSession*****#*#*****SqlSession*****#*#*****[mybatis-spring-2.1.2.jar:2.1.2] at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:147) ~[mybatis-3.5.13.jar:3.5.13] at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:80) ~[mybatis-3.5.13.jar:3.5.13] at org.apache.ibatis.binding.MapperProxy$PlainMethodInvoker.invoke(MapperProxy.java:142) ~[mybatis-3.5.13.jar:3.5.13] at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:86) ~[mybatis-3.5.13.jar:3.5.13] at com.sun.proxy.$Proxy357.getWorkorderFullsetList(Unknown Source) ~[?:?] at com.huawei.it.tgmes.tmas.wavejuxin.service.impl.WorkorderFullsetServiceImpl.getWorkorderFullsetListByPage(WorkorderFullsetServiceImpl.java:152) ~[classes/:?] at com.huawei.it.tgmes.tmas.wavejuxin.service.impl.WorkorderFullsetServiceImpl$$FastClassBySpringCGLIB$$44870253.invoke(<generated>) ~[classes/:?] at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) ~[spring-core-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:792) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:64) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:57) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:58) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.aspectj.AspectJAfterThrowingAdvice.invoke(AspectJAfterThrowingAdvice.java:64) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.adapter.AfterReturningAdviceInterceptor.invoke(AfterReturningAdviceInterceptor.java:57) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.adapter.MethodBeforeAdviceInterceptor.invoke(MethodBeforeAdviceInterceptor.java:58) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:123) ~[spring-tx-5.3.39-h2.jar:5.3.39-h2] at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:388) ~[spring-tx-5.3.39-h2.jar:5.3.39-h2] at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:119) ~[spring-tx-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:175) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at com.huawei.it.jalor5.security.service.impl.internal.SecurityInterceptor.invoke(SecurityInterceptor.java:117) ~[jalor-auth*****#*#*****LEASE.jar:6.6.8.0.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at com.huawei.it.jalor5.security.service.impl.internal.SecurityInterceptor.invoke(SecurityInterceptor.java:117) ~[jalor-auth*****#*#*****LEASE.jar:6.6.8.0.RELEASE] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:762) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:707) ~[spring-aop-5.3.39-h2.jar:5.3.39-h2] at com.huawei.it.tgmes.tmas.wavejuxin.service.impl.WorkorderFullsetServiceImpl$$EnhancerBySpringCGLIB$$ed6df9c8.getWorkorderFullsetListByPage(<generated>) ~[classes/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_332] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_332] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_332] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_332] at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) ~[cxf-core-3.5.11.jar:3.5.11] at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) ~[cxf-core-3.5.11.jar:3.5.11] at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:201) ~[cxf-rt-frontend-jaxrs-3.5.11.jar:3.5.11] at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(JAXRSInvoker.java:104) ~[cxf-rt-frontend-jaxrs-3.5.11.jar:3.5.11] at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) ~[cxf-core-3.5.11.jar:3.5.11] at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:96) ~[cxf-core-3.5.11.jar:3.5.11] at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) ~[cxf-core-3.5.11.jar:3.5.11] at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121) ~[cxf-core-3.5.11.jar:3.5.11] at org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:267) ~[cxf-rt-transports-http-3.5.11.jar:3.5.11] at org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:234) ~[cxf-rt-transports-http-3.5.11.jar:3.5.11] at org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:208) ~[cxf-rt-transports-
最新发布
10-22
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值