gpt4 book ai didi

JAVA - 为什么从 SOAP UI 获取 ElementNSImpl

转载 作者:行者123 更新时间:2023-12-02 11:05:17 30 4
gpt4 key购买 nike

我正在尝试从 SOAP UI 检索值。我能够获取除一个元素之外的所有元素值,并获取为“[prim:Usercount: null]”而不是 Usercount 值。

在 Debug模式下查看时,显示的 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 用户界面:

<prim:XMLRequest>
<prim:Reference>aa</prim:Reference>
<!--Optional:-->
<prim:Number>1</prim:Number>
<!--Optional:-->
<prim:Usercount>150</prim:Usercount>
</prim:XMLRequest>

任何人都可以对此提出建议吗?

最佳答案

你的类(class)成员不一致。你有

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;

关于JAVA - 为什么从 SOAP UI 获取 ElementNSImpl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51016634/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com