隨筆 - 119  文章 - 3173  trackbacks - 0
          <2007年10月>
          30123456
          78910111213
          14151617181920
          21222324252627
          28293031123
          45678910

          交友莫獨酒,茅臺西鳳游。
          口干古井貢,心徜洋河流。
          稱多情杜康,趟無量雙溝。
          贊中華巍巍,無此不銷愁。

          常用鏈接

          留言簿(68)

          隨筆分類(136)

          隨筆檔案(122)

          最新隨筆

          搜索

          •  

          積分與排名

          • 積分 - 526781
          • 排名 - 92

          最新評論

          服務端:

          ?1?import?java.util.ArrayList;
          ?2?import?java.util.List;
          ?3?import?javax.jws.WebMethod;
          ?4?import?javax.jws.WebService;
          ?5?import?javax.jws.soap.SOAPBinding;
          ?6?
          ?7?@WebService(targetNamespace?=?"http://jdk.study.hermit.org/testlist")
          ?8?@SOAPBinding(style?=?SOAPBinding.Style.RPC)
          ?9?public?class?GetList?{
          10?????@WebMethod
          11?????public?List<UserInfo>?sayHello(int?n)?{
          12?????????List<UserInfo>?userlist?=?new?ArrayList<UserInfo>();
          13?????????for?(int?i?=?0;?i?<?n;?i++)?{
          14?????????????UserInfo?user?=?new?UserInfo();
          15?????????????user.setId(i);
          16?????????????user.setName("name"+i);
          17?????????????userlist.add(user);
          18?????????}
          19?????????return?userlist;
          20?????}
          21?}
          啟動時報錯:
          ??1?嚴重:?StandardWrapper.Throwable
          ??2?Server?Runtime?Error:?javax.xml.ws.WebServiceException
          ??3?????at?com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:269)
          ??4?????at?com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:87)
          ??5?????at?com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:59)
          ??6?????at?javax.xml.ws.Endpoint.publish(Endpoint.java:156)
          ??7?????at?WebServiceStarter.init(WebServiceStarter.java:21)
          ??8?????at?javax.servlet.GenericServlet.init(GenericServlet.java:212)
          ??9?????at?org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
          ?10?????at?org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
          ?11?????at?org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4044)
          ?12?????at?org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
          ?13?????at?org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
          ?14?????at?org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
          ?15?????at?org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
          ?16?????at?org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
          ?17?????at?org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
          ?18?????at?org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
          ?19?????at?org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
          ?20?????at?org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
          ?21?????at?org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
          ?22?????at?org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
          ?23?????at?org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
          ?24?????at?org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
          ?25?????at?org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
          ?26?????at?org.apache.catalina.core.StandardService.start(StandardService.java:451)
          ?27?????at?org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
          ?28?????at?org.apache.catalina.startup.Catalina.start(Catalina.java:552)
          ?29?????at?sun.reflect.NativeMethodAccessorImpl.invoke0(Native?Method)
          ?30?????at?sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          ?31?????at?sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          ?32?????at?java.lang.reflect.Method.invoke(Method.java:597)
          ?33?????at?org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
          ?34?????at?org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
          ?35?Caused?by:?javax.xml.ws.WebServiceException
          ?36?????at?com.sun.xml.internal.ws.model.RuntimeModel.createJAXBContext(RuntimeModel.java:201)
          ?37?????at?com.sun.xml.internal.ws.model.RuntimeModel.postProcess(RuntimeModel.java:79)
          ?38?????at?com.sun.xml.internal.ws.modeler.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:255)
          ?39?????at?com.sun.xml.internal.ws.server.RuntimeEndpointInfo.createSEIModel(RuntimeEndpointInfo.java:170)
          ?40?????at?com.sun.xml.internal.ws.server.RuntimeEndpointInfo.init(RuntimeEndpointInfo.java:317)
          ?41?????at?com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:298)
          ?42?????at?com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:263)
          ?43??????31?more
          ?44?Caused?by:?com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException:?1?counts?of?IllegalAnnotationExceptions
          ?45?java.util.List?is?an?interface,?and?JAXB?can't?handle?interfaces.
          ?46?????this?problem?is?related?to?the?following?location:
          ?47?????????at?java.util.List
          ?48?
          ?49?????at?com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:66)
          ?50?????at?com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:361)
          ?51?????at?com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:217)
          ?52?????at?com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
          ?53?????at?sun.reflect.NativeMethodAccessorImpl.invoke0(Native?Method)
          ?54?????at?sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          ?55?????at?sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          ?56?????at?java.lang.reflect.Method.invoke(Method.java:597)
          ?57?????at?com.sun.xml.internal.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:76)
          ?58?????at?com.sun.xml.internal.ws.model.RuntimeModel$1.run(RuntimeModel.java:196)
          ?59?????at?java.security.AccessController.doPrivileged(Native?Method)
          ?60?????at?com.sun.xml.internal.ws.model.RuntimeModel.createJAXBContext(RuntimeModel.java:193)
          ?61??????37?more
          ?62?2007-1-19?9:53:07?org.apache.catalina.core.StandardContext?loadOnStartup
          ?63?嚴重:?Servlet?/java6.web.service?threw?load()?exception
          ?64?com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException:?1?counts?of?IllegalAnnotationExceptions
          ?65?java.util.List?is?an?interface,?and?JAXB?can't?handle?interfaces.
          ?66?????this?problem?is?related?to?the?following?location:
          ?67?????????at?java.util.List
          ?68?
          ?69?????at?com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:66)
          ?70?????at?com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:361)
          ?71?????at?com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:217)
          ?72?????at?com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
          ?73?????at?sun.reflect.NativeMethodAccessorImpl.invoke0(Native?Method)
          ?74?????at?sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          ?75?????at?sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          ?76?????at?java.lang.reflect.Method.invoke(Method.java:597)
          ?77?????at?com.sun.xml.internal.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:76)
          ?78?????at?com.sun.xml.internal.ws.model.RuntimeModel$1.run(RuntimeModel.java:196)
          ?79?????at?java.security.AccessController.doPrivileged(Native?Method)
          ?80?????at?com.sun.xml.internal.ws.model.RuntimeModel.createJAXBContext(RuntimeModel.java:193)
          ?81?????at?com.sun.xml.internal.ws.model.RuntimeModel.postProcess(RuntimeModel.java:79)
          ?82?????at?com.sun.xml.internal.ws.modeler.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:255)
          ?83?????at?com.sun.xml.internal.ws.server.RuntimeEndpointInfo.createSEIModel(RuntimeEndpointInfo.java:170)
          ?84?????at?com.sun.xml.internal.ws.server.RuntimeEndpointInfo.init(RuntimeEndpointInfo.java:317)
          ?85?????at?com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:298)
          ?86?????at?com.sun.xml.internal.ws.transport.http.server.HttpEndpoint.publish(HttpEndpoint.java:263)
          ?87?????at?com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:87)
          ?88?????at?com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:59)
          ?89?????at?javax.xml.ws.Endpoint.publish(Endpoint.java:156)
          ?90?????at?WebServiceStarter.init(WebServiceStarter.java:21)
          ?91?????at?javax.servlet.GenericServlet.init(GenericServlet.java:212)
          ?92?????at?org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1161)
          ?93?????at?org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:981)
          ?94?????at?org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:4044)
          ?95?????at?org.apache.catalina.core.StandardContext.start(StandardContext.java:4350)
          ?96?????at?org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:760)
          ?97?????at?org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:740)
          ?98?????at?org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
          ?99?????at?org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:920)
          100?????at?org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:883)
          101?????at?org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:492)
          102?????at?org.apache.catalina.startup.HostConfig.start(HostConfig.java:1138)
          103?????at?org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
          104?????at?org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
          105?????at?org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1022)
          106?????at?org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
          107?????at?org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
          108?????at?org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
          109?????at?org.apache.catalina.core.StandardService.start(StandardService.java:451)
          110?????at?org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
          111?????at?org.apache.catalina.startup.Catalina.start(Catalina.java:552)
          112?????at?sun.reflect.NativeMethodAccessorImpl.invoke0(Native?Method)
          113?????at?sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
          114?????at?sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
          115?????at?java.lang.reflect.Method.invoke(Method.java:597)
          116?????at?org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
          117?????at?org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
          修改服務端代碼:
          ?1?import?java.util.ArrayList;
          ?2?import?javax.jws.WebMethod;
          ?3?import?javax.jws.WebService;
          ?4?import?javax.jws.soap.SOAPBinding;
          ?5?
          ?6?@WebService(targetNamespace?=?"http://jdk.study.hermit.org/testlist")
          ?7?@SOAPBinding(style?=?SOAPBinding.Style.RPC)
          ?8?public?class?GetList?{
          ?9?????@WebMethod
          10?????public?ArrayList<UserInfo>?getList(int?n)?{
          11?????????ArrayList<UserInfo>?userlist?=?new?ArrayList<UserInfo>();
          12?????????for?(int?i?=?0;?i?<?n;?i++)?{
          13?????????????UserInfo?user?=?new?UserInfo();
          14?????????????user.setId(i);
          15?????????????user.setName("name"+i);
          16?????????????userlist.add(user);
          17?????????}
          18?????????return?userlist;
          19?????}
          20?}
          啟動OK

          但是客戶端
          執(zhí)行wsimport -keep? http://localhost:8080/ListService?wsdl,一共生成了7個文件
          AbstractCollection.java
          AbstractList.java
          ArrayList.java
          GetList.java
          GetListService.java
          ObjectFactory.java
          package-info.java

          測試代碼
          ?1?package?test;
          ?2?
          ?3?import?static?org.junit.Assert.assertNotNull;
          ?4?import?org.hermit.study.jdk.testlist.ArrayList;
          ?5?import?org.hermit.study.jdk.testlist.GetList;
          ?6?import?org.hermit.study.jdk.testlist.GetListService;
          ?7?import?org.junit.Test;
          ?8?
          ?9?public?class?TestList?{
          10?????@Test
          11?????public?void?getList()?{
          12?????????GetListService?service?=?new?GetListService();
          13?????????GetList?obj?=?service.getGetListPort();
          14?????????
          15?????????ArrayList?userlist?=?obj.getList(5);
          16?????????assertNotNull(userlist);
          17?????????
          18?????}
          19?}
          可以看到ArrayList?userlist?=?obj.getList(5);中的list是org.hermit.study.jdk.testlist.ArrayList;
          而非util的list

          郁悶,繼續(xù)找資料看看怎么傳list吧
          posted on 2007-01-19 10:55 交口稱贊 閱讀(4706) 評論(6)  編輯  收藏 所屬分類: Java6

          FeedBack:
          # re: 學習Java6(一) WebServices (5)傳遞List(失敗) 2007-01-19 22:42 duoxie
          加油  回復  更多評論
            
          # re: 學習Java6(一) WebServices (5)傳遞List(失敗) 2007-01-23 23:39 小車馬
          還沒學到那里去,先感受下,呵呵

          樓主,潛力貼論壇(http://content.uu1001.com)是我個人的一個設想,如果你對java非常的專注,并且愿意交我這個朋友,可以發(fā)郵件給我(lbw070105@gmail.com),希望我們可以一起發(fā)展它。  回復  更多評論
            
          # re: 學習Java6(一) WebServices (5)傳遞List(失敗) 2007-10-23 23:49 不_神
          有人有解答了嗎?  回復  更多評論
            
          # re: 學習Java6(一) WebServices (5)傳遞List(失敗) 2007-10-24 08:49 交口稱贊
          有了
          搞定了  回復  更多評論
            
          # re: 學習Java6(一) WebServices (5)傳遞List(失敗) 2009-09-24 08:42 flow
          怎樣解決的?我也遇到這個問題啦、  回復  更多評論
            
          # re: 學習Java6(一) WebServices (5)傳遞List(失敗) 2010-08-26 14:09 DavidYoung
          主要原因是
          SOAPBinding.ParameterStyle.BARE
          改為
          SOAPBinding.ParameterStyle.WRAPPED

          就可以了。

          msn:yangjiabo@hotmail.com  回復  更多評論
            
          主站蜘蛛池模板: 侯马市| 玉环县| 武清区| 东光县| 华亭县| 筠连县| 达尔| 慈溪市| 阆中市| 长顺县| 彭山县| 县级市| 社会| 库尔勒市| 兴隆县| 曲麻莱县| 晋州市| 崇信县| 贵阳市| 凤庆县| 陆丰市| 远安县| 洛宁县| 如皋市| 平谷区| 镇平县| 新河县| 阿拉尔市| 禹州市| 马公市| 杭州市| 电白县| 图片| 巴彦淖尔市| 西青区| 满城县| 泊头市| 辽源市| 集贤县| 崇仁县| 宁国市|