从蚂蚁在wsimport生成的类摆脱的JAXBElement叫 [英] Get rid of JAXBElement in classes generated by wsimport called from ant

查看:675
本文介绍了从蚂蚁在wsimport生成的类摆脱的JAXBElement叫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下问题:
我使用的wsimport Ant任务来创建一个Web服务客户端(salesforce.com)。
一切都工作正常,但生成的类都使用这种奇怪的JAXBElement类所有bean属性。

例如:


 公共无效setLastName(JAXBElement的<串GT;值){
    this.lastName =((JAXBElement的<串GT;)值);
}公众的JAXBElement<串GT; getCountry(){
    返回的国家;
}


而不是包装在JAXBElement的所有类的,我想用简单的方法,如setLastName(字符串newLastName)。
这就是我如何调用的wsimport任务。

 < wsimport的调试=false的详细=假保持=$ {}保持
   扩展=$ {}扩展DESTDIR =$ {} tmp.metro
   WSDL =$ {} licensing.wsdl
   sourcedestdir =$ {} licensingws.generated.src   >   <结合DIR =$ {BASEDIR} /等包括=$ {} client.binding
     />
    < ARG值= - B-XautoNameResolution/>  < / wsimport的>

该任务的定义是这样的:


  
 

有谁知道我必须设定这样的wsimport生成的类我想要的方式?
非常感谢事先!


解决方案

原因在生成的bean使用的JAXBElement包装可能是,该WSDL声明领域既可选的nillable。为未present和present,但空,字符串型,不能直接使用,因为在两种情况下,字符串将是空。区分

如果你不需要这两种情况加以区分,可以配置code发电机来使用String类型来代替。我不是100%确定如何使用Ant任务做到这一点,但你可能会发现Ant任务文档中的相关信息。

I have the following problem: I'm using the wsimport ant task to create a webservice client (for salesforce.com). Everything's working fine but the generated classes all use this strange JAXBElement class for all bean properties.

Eg:

public void setLastName(JAXBElement<String> value) {
    this.lastName = ((JAXBElement<String> ) value);
}

public JAXBElement<String> getCountry() {
    return country;
}

Instead of wrapping all classes in JAXBElement I'd like to have simple methods like setLastName(String newLastName). That's how I'm calling the wsimport task.

<wsimport debug="false" verbose="false" keep="${keep}" 
   extension="${extension}" destdir="${tmp.metro}" 
   wsdl="${licensing.wsdl}" 
   sourcedestdir="${licensingws.generated.src}"

   >

   <binding dir="${basedir}/etc" includes="${client.binding}"   
     />
    <arg value="-B-XautoNameResolution" />

  </wsimport>

The task is defined this way:

Does anybody know what I have to set so that wsimport generates the classes the way I want? Thanks a lot in advance!!!

解决方案

The reason for using JAXBElement wrappers in the generated beans is probably, that the WSDL declares the field to be both optional and nillable. To distinguish between "not present" and "present, but null", the String type cannot be used directly, since the String in both cases would be null.

If you don't need to distinguish between the two situations, you can configure the code generator to use the String type instead. I'm not 100% sure how to do this with the ant task, but you'll probably find the relevant information in the ant task documentation.

这篇关于从蚂蚁在wsimport生成的类摆脱的JAXBElement叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆