论坛首页 入门讨论版 SOA

cxf的WebService实现中,方法不能给参数传空指针

浏览 463 次
该帖已经被评为新手帖
作者 正文
时间:2007-10-15

      项目中使用cxf作WebService的实现。但是在调用一个方法的时候,在客户端就出错,说是IllegalArgumentException。昨晚加班到凌晨4点,才找到原因。原来,在服务方法中有一个String类型的参数,当给这个参数传空指针的时候,就会出错。

      cxf也太弱了吧?给参数传空指针就会出错,而且错误信息十分不友好。为什么不提示说是空指针呢?或者干脆就支持空指针好了。

   
时间:2007-10-15
你是采用WSDL First 还是Code First来发布你的服务的, 我记得如果采用WSDL First的话,将参数的Element设置为nillable。
还有你采用Code First的话, 可以通过JAXWS API 中Annotation 设置你的来参数的内容。

JAXB has the ability to specify that stuff with attributes on the 
XmlElement annotation. JAX-WS allows you to define a "wrapper" type
that the runtime uses to for IO. Thus, you can create the wrapper type
with the annotations that you want and then use the @RequestWrapper and
@ResponseWrapper annotations to point the JAX-WS runtime at it.
   
0 请登录后投票
论坛首页 入门讨论版 SOA

跳转论坛:
快速回复 引用上一条消息 (Alt+S)