我正在尝试从SOAP UI检索值。我可以获取除一个元素以外的所有元素值,并获取“ [prim:Usercount: null]
”而不是Usercount值。
在调试模式下查看时,显示的Usercount值为ElementNSImpl。
请找到以下代码:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "UserListRequest", propOrder = {
"reference",
"number",
"usercount"
})
public class UserListRequest extends Arguments implements java.io.Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlElement(name = "Reference", required = true)
@XmlSchemaType(name = "string")
protected UserListReferenceTypes reference;
@XmlElement(name = "Number")
protected String number;
@XmlElement(name = "Usercount")
protected Object usercount;
//Seeters & getters
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(UserListRequest.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("http://*.*./*.Services", "UserListRequest"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("reference");
elemField.setXmlName(new javax.xml.namespace.QName("http://*.*./*.Services", "Reference"));
elemField.setXmlType(new javax.xml.namespace.QName("http://*.*./*.Services", "UserListReferenceTypes"));
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("number");
elemField.setXmlName(new javax.xml.namespace.QName("http://*.*./*.Services", "Number"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("usercount");
elemField.setXmlName(new javax.xml.namespace.QName("http://*.*./*.Services", "usercount"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "anyType"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
}
/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}
/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}
/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}
}
SOAP UI:
<prim:XMLRequest>
<prim:Reference>aa</prim:Reference>
<!--Optional:-->
<prim:Number>1</prim:Number>
<!--Optional:-->
<prim:Usercount>150</prim:Usercount>
</prim:XMLRequest>
有人可以提出建议吗?
答案 0 :(得分:1)
您的班级成员不一致。你有
private static final long serialVersionUID = 1L;
@XmlElement(name = "Reference", required = true)
@XmlSchemaType(name = "string")
protected UserListReferenceTypes reference;
@XmlElement(name = "Number")
protected String number;
@XmlElement(name = "Usercount")
protected Object usercount;
代替
private static final long serialVersionUID = 1L;
@XmlElement(name = "Reference", required = true)
@XmlSchemaType(name = "string")
protected UserListReferenceTypes reference;
@XmlElement(name = "Number")
@XmlSchemaType(name = "int")
protected int number;
@XmlElement(name = "Usercount")
@XmlSchemaType(name = "int")
protected int usercount;