我正在尝试使用RSA7.5和Websphere 7服务器开发一个服务。由于我是初学者,因此我遵循Java类优先方法,即首先创建Java类,然后生成WSDL文件。
当我尝试创建wsdl文件时,我得到了一个异常:
IllegalAnnotationsException类的java.security.PrivilegedActionException:com.sun.xml.internal.bind.v2.runtime.IllegalAnnotationsException: 1 counts有两个同名的属性"planId"
我在这里引用的类看起来像这样:
public class MemberDetails{
@XMLElement(required=true)
private String planId;
//public getters and setters for the planId;
}
我不知道为什么会发生这种异常。通过谷歌搜索,我尝试了一些替代方案来解决这个问题,但它们都不适用于我:
备注:
这是我在整个工作空间中唯一使用的注释。我不确定这是否依赖于其他一些注释。但是我尝试了一些,比如@XMLElement(name=“计划”,required=true),@XMLType,等等,但是每次我都会得到这个异常。
此异常发生在wsgen过程中。(java.lang.reflect.InvocationTargetException)
编辑
基本上,当我们从java服务方法创建wsdl并在SOAP UI中打开该WSDL时,我们将在每个元素的顶部获得<!--Optional-->
。我想删除这个选项标记<!--Optional-->
标记,因此我尝试使用@XMLElement(required=true)方法,这样当我在SOAP UI中打开WSDL时,强制元素就不会出现<!--Optional-->
。
根据我的概念,@XMLElement(required=true)会将minOccurs设置为1,即大于零,因此当我在SOAP UI中打开它时,可选注释将从WSDL中删除。但不幸的是,它不工作,因此我的概念是错误的。在生成WSDL之后,我可以看到minOccurs仍然是0。
请解释在SOAP UI中打开WSDL时如何删除可选标记。
致以敬意,
发布于 2012-09-13 01:06:02
默认情况下,实现处理公共访问器方法和带注释的字段。如果你注释了一个你也有get/set方法的字段,你会得到这个异常:
如果要注释字段,则应指定@XmlAccessorType(XmlAccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
public class MemberDetails{
@XMLElement(required=true)
private String planId;
//public getters and setters for the planId;
}
或者,您可以注释该属性
public class MemberDetails{
private String planId;
@XMLElement(required=true)
public String getPlanId() {
return planId;
}
}
有关详细信息的,请访问
发布于 2014-10-14 04:48:41
对于JAXB2.0,在getter或setter上使用@XmlTransient
进行注释可以防止冲突。
点击此处查看更多信息:http://docs.oracle.com/javase/8/docs/api/javax/xml/bind/annotation/XmlTransient.html
https://stackoverflow.com/questions/12392235
复制相似问题