做接口的时候。一直调用不到接口。执行返回为500
这是控制台给的警告。
其他就没错误信息了。
2009-8-23 21:03:23 org.apache.cxf.jaxrs.provider.AbstractJAXBProvider handleJAXBException
警告: JAXBException occurred : 1 counts of IllegalAnnotationExceptions
2009-8-23 21:03:23 org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
警告: WebApplicationException has been caught : 1 counts of IllegalAnnotationExceptions
这是测试类代码:
- Java code
@Test public void testSaveOrUpdate(){ String url = "http://localhost:8081/services/userservices/adduser"; HttpClient httpClient = new HttpClient(); PostMethod postMethod = new PostMethod(url); postMethod.setRequestHeader("Content-type","application/xml"); postMethod.setRequestHeader("user", "vis"); postMethod.setRequestHeader("pass", "vis@amoy"); postMethod.setRequestEntity(new InputStreamRequestEntity(this.getClass().getResourceAsStream("testAddUsers.xml"))); try{ int status = httpClient.executeMethod(postMethod); if(status == HttpStatus.SC_OK){ System.out.println(new String(postMethod.getResponseBody(), "utf-8")); } }catch (HttpException e) { throw new RuntimeException("",e); } catch (IOException e) { throw new RuntimeException("",e); }finally{ postMethod.releaseConnection(); } }
这是service代码:
- Java code
@Path("/userservices/")@Produces("application/xml")public class UserService { @Context private org.apache.cxf.jaxrs.ext.MessageContext messageContext; @POST @Path("/adduser") @Consumes("application/xml") public Response saveOrUpdate(VisUsers users) { if(Authentication.validate(messageContext)){ int result=userDao.saveOrUpdate(users); if(result>0){ return Response.status(200).entity("Save OK!").build(); }else{ return Response.status(401).entity("insert user error!").build(); } }else{ return Response.status(401).build(); } }
配置文件:
- Java code
<bean id="userservices" class="com.sns.bestv.service.impl.UserService"> <property name="userDao" ref="userDao"></property> </bean> <jaxrs:server id="mmberService_wa" address="/"> <jaxrs:serviceBeans> <ref bean="mmberService" /> <ref bean="userservices" /> </jaxrs:serviceBeans> </jaxrs:server>
我测试为撒到不了接口呢?
应该说是到接口了。因为返回是500不是404应该证明是有到接口这边了。
可是那个警告什么意思?
------解决方案--------------------
等待高手