参考: http://53873039oycg.iteye.com/blog/1979421
今天学了下Jax-Ws的一个简单的例子,刚开始发布时遇到如下错误:
Java代码
com.sun.xml.internal.ws.model.RuntimeModelerException: runtime modeler error: Wrapper class com.test.service.jaxws.add is not found. Have you run APT to generate them? SOAPBinding
网上查了下资料,说是要指定
Java代码
原因:
1 SOAPBinding的style默认为SOAPBinding.Style.DOCUMENT,要修改为RPC 2 Jdk1.6版本低,换个高点的版本就可以了
于是在接口上指定绑定的类型
Java代码
@SOAPBinding(style = SOAPBinding.Style.RPC)
中午时候,想着以后每次都要写这么一行,麻烦,就把电脑上的jdk1.6.0.10换成了jdk1.6.0.32。
下午试着返回List<User>类型,以前用过CXF,记得CXF的Jax-Ws返回List<JavaBean>这种类型是不需要配置的,结果刚发布就报错,错误信息如下:
Java代码
-
Exception in thread "main" javax.xml.ws.WebServiceException: Unable to create JAXBContext at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:153) at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:83) at com.sun.xml.internal.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:244) at com.sun.xml.internal.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:312) at com.sun.xml.internal.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:178) at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:456) at com.sun.xml.internal.ws.api.server.WSEndpoint.create(WSEndpoint.java:475) at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.createEndpoint(EndpointImpl.java:213) at com.sun.xml.internal.ws.transport.http.server.EndpointImpl.publish(EndpointImpl.java:143) at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:102) at javax.xml.ws.Endpoint.publish(Endpoint.java:170) at com.huse.ws.basic.chap.server.test.MyServer.main(MyServer.java:13) Caused by: java.security.PrivilegedActionException: com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 2 counts of IllegalAnnotationExceptions java.util.List is an interface, and JAXB can‘t handle interfaces. this problem is related to the following location: at java.util.List java.util.List does not have a no-arg default constructor. this problem is related to the following location: at java.util.List at java.security.AccessController.doPrivileged(Native Method) at com.sun.xml.internal.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:140) ... 11 more
遇到错误自己又不会于是谷歌了下,没找到我要的,又百度了下,网上说加上
Java代码
-
@SOAPBinding(style = SOAPBinding.Style.RPC) @WebMethod
就OK了,RPC我有,就在实现类上加了@WebMethod,一发布还是报错,在又百度几次无果后,一次偶然的机会我把
Java代码
@SOAPBinding(style = SOAPBinding.Style.RPC)
这一行删了,再次发布,结果如下:
Java代码
-
2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass 信息: Dynamically creating request wrapper Class com.huse.ws.basic.chap.server.inter.jaxws.Plus 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass 信息: Dynamically creating response wrapper bean Class com.huse.ws.basic.chap.server.inter.jaxws.PlusResponse 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass 信息: Dynamically creating request wrapper Class com.huse.ws.basic.chap.server.inter.jaxws.Minus 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass 信息: Dynamically creating response wrapper bean Class com.huse.ws.basic.chap.server.inter.jaxws.MinusResponse 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass 信息: Dynamically creating request wrapper Class com.huse.ws.basic.chap.server.inter.jaxws.AddUser 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass 信息: Dynamically creating response wrapper bean Class com.huse.ws.basic.chap.server.inter.jaxws.AddUserResponse 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass 信息: Dynamically creating request wrapper Class com.huse.ws.basic.chap.server.inter.jaxws.GetUser 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass 信息: Dynamically creating response wrapper bean Class com.huse.ws.basic.chap.server.inter.jaxws.GetUserResponse 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass 信息: Dynamically creating request wrapper Class com.huse.ws.basic.chap.server.inter.jaxws.ListUser 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass 信息: Dynamically creating response wrapper bean Class com.huse.ws.basic.chap.server.inter.jaxws.ListUserResponse 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getRequestWrapperClass 信息: Dynamically creating request wrapper Class com.huse.ws.basic.chap.server.inter.jaxws.Login 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getResponseWrapperClass 信息: Dynamically creating response wrapper bean Class com.huse.ws.basic.chap.server.inter.jaxws.LoginResponse 2013-11-22 14:38:08 com.sun.xml.internal.ws.model.RuntimeModeler getExceptionBeanClass 信息: Dynamically creating exception bean Class com.huse.ws.basic.chap.server.inter.jaxws.UserExceptionBean
OK了。
再次说明,本次Jdk版本是jdk.1.6.0.32,Jdk1.6.0.10上面我没测试过。
时间: 2024-10-09 23:25:33