JAVA - 在测试 SOAP Web 服务时从 SOAP UI 获取空值
JAVA - Getting null values from SOAP UI while testing SOAP Web Services
我正在使用 AXIS 1.4
生成的 classes 开发 SOAP 客户端。从 SoAP UI 进行测试时,将值(Title & LastName 字段如下面的代码所示)设为 null。
对于 ApplicationPersonEntity 中可用的所有字段 class 变为空。
请找到以下代码:
public class ApplicationCustomerEntity implements java.io.Serializable
{
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlElement(name = "People")
private List<ApplicationPersonEntity> people;
//Setters & getters
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(ApplicationCustomerEntity.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("*..Services", "ApplicationCustomerEntity"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("people");
elemField.setXmlName(new javax.xml.namespace.QName("*..Services", "People"));
elemField.setXmlType(new javax.xml.namespace.QName("*..Services", "ApplicationPersonEntity"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
elemField.setItemQName(new javax.xml.namespace.QName("*..Services", "ApplicationPersonEntity"));
typeDesc.addFieldDesc(elemField);
}
//Serilizer & Deserilizer methods
}
ApplicationPersonEntity.java
public class ApplicationPersonEntity implements Serializable
{
@XmlElement(name = "Title")
protected String title;
@XmlElement(name = "LastName")
protected String lastName;
//Consctor& Setters getters
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(ApplicationPersonEntity.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("*..Services", "ApplicationPersonEntity"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("title");
elemField.setXmlName(new javax.xml.namespace.QName("*..Services", "Title"));
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("lastName");
elemField.setXmlName(new javax.xml.namespace.QName("*..Services", "LastName"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
}
//Serilizer & De Serilizer methods
}
在ApplicationCustomerEntity.java
而不是
typeDesc.setXmlType(new javax.xml.namespace.QName("*..Services", "ApplicationCustomerEntity"));
试试这个
假设你的ApplicationCustomerEntity.java在CustomerList.java
下使用
typeDesc.setXmlType(new javax.xml.namespace.QName("http://Services/CustomerList/ApplicationCustomerEntity", ">ApplicationCustomerEntity"));
在ApplicationPersonEntity.java
而不是
typeDesc.setXmlType(new javax.xml.namespace.QName("*..Services", "ApplicationPersonEntity"));
试试这个
typeDesc.setXmlType(new javax.xml.namespace.QName("http://Services/CustomerList/ApplicationCustomerEntity/ApplicationPersonEntity", ">ApplicationPersonEntity"));
使用以下标签解决了问题:
@XmlElementWrapper(name="People")
@XmlElement(name="ApplicationPersonEntity")
private List<ApplicationPersonEntity> people;
我正在使用 AXIS 1.4
生成的 classes 开发 SOAP 客户端。从 SoAP UI 进行测试时,将值(Title & LastName 字段如下面的代码所示)设为 null。
对于 ApplicationPersonEntity 中可用的所有字段 class 变为空。
请找到以下代码:
public class ApplicationCustomerEntity implements java.io.Serializable
{
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlElement(name = "People")
private List<ApplicationPersonEntity> people;
//Setters & getters
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(ApplicationCustomerEntity.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("*..Services", "ApplicationCustomerEntity"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("people");
elemField.setXmlName(new javax.xml.namespace.QName("*..Services", "People"));
elemField.setXmlType(new javax.xml.namespace.QName("*..Services", "ApplicationPersonEntity"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
elemField.setItemQName(new javax.xml.namespace.QName("*..Services", "ApplicationPersonEntity"));
typeDesc.addFieldDesc(elemField);
}
//Serilizer & Deserilizer methods
}
ApplicationPersonEntity.java
public class ApplicationPersonEntity implements Serializable
{
@XmlElement(name = "Title")
protected String title;
@XmlElement(name = "LastName")
protected String lastName;
//Consctor& Setters getters
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(ApplicationPersonEntity.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("*..Services", "ApplicationPersonEntity"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("title");
elemField.setXmlName(new javax.xml.namespace.QName("*..Services", "Title"));
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("lastName");
elemField.setXmlName(new javax.xml.namespace.QName("*..Services", "LastName"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
}
//Serilizer & De Serilizer methods
}
在ApplicationCustomerEntity.java
而不是
typeDesc.setXmlType(new javax.xml.namespace.QName("*..Services", "ApplicationCustomerEntity"));
试试这个 假设你的ApplicationCustomerEntity.java在CustomerList.java
下使用typeDesc.setXmlType(new javax.xml.namespace.QName("http://Services/CustomerList/ApplicationCustomerEntity", ">ApplicationCustomerEntity"));
在ApplicationPersonEntity.java
而不是
typeDesc.setXmlType(new javax.xml.namespace.QName("*..Services", "ApplicationPersonEntity"));
试试这个
typeDesc.setXmlType(new javax.xml.namespace.QName("http://Services/CustomerList/ApplicationCustomerEntity/ApplicationPersonEntity", ">ApplicationPersonEntity"));
使用以下标签解决了问题:
@XmlElementWrapper(name="People")
@XmlElement(name="ApplicationPersonEntity")
private List<ApplicationPersonEntity> people;