在Java中使用AXIS在SOAP响应中将Enum值获取为Null

时间:2018-07-27 06:50:19

标签: java spring-boot soap axis soap-client

当服务器发送正确的响应时,但当我查看该枚举返回值时,我在SOAP响应中得到的Enum为空值(在setter()中检查)。服务器也将返回枚举值作为响应。

由于我找不到问题,即使枚举返回值(在setter()中检查),客户端SOAP Response中的字段为何都为空。

请从SOAP客户端响应中找到该字段的响应输出,如下所示:

<ns3:AppSource/>

请找到以下代码详细信息:

@XmlType(name = "AppSourceSelector")
@XmlEnum
public class AppSourceSelector implements java.io.Serializable {
    private java.lang.String _value_;
    private static java.util.HashMap _table_ = new java.util.HashMap();

    // Constructor
    protected AppSourceSelector(java.lang.String value) {
        _value_ = value;
        _table_.put(_value_,this);
    }

    public static final java.lang.String _SCREEN = "SCREEN";
    public static final java.lang.String _API = "API";
    public static final java.lang.String _FILE = "FILE";
    public static final AppSourceSelector SCREEN = new AppSourceSelector(_SCREEN);
    public static final AppSourceSelector API = new AppSourceSelector(_API);
    public static final AppSourceSelector FILE = new AppSourceSelector(_FILE);

    public java.lang.String getValue() { return _value_;}

    public static AppSourceSelector fromValue(java.lang.String value)
          throws java.lang.IllegalArgumentException {
        System.out.println("value:>>>>>>"+value);
        AppSourceSelector enumeration = (AppSourceSelector)
            _table_.get(value);
        if (enumeration==null) throw new java.lang.IllegalArgumentException();

        System.out.println("enumeration:>>>>>>"+enumeration);
        return enumeration;
    }
    public static AppSourceSelector fromString(java.lang.String value)
          throws java.lang.IllegalArgumentException {
        return fromValue(value);
    }
    public boolean equals(java.lang.Object obj) {return (obj == this);}
    public int hashCode() { return toString().hashCode();}
    public java.lang.String toString() { return _value_;}
    public java.lang.Object readResolve() throws java.io.ObjectStreamException { return fromValue(_value_);}

    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.EnumSerializer(
            _javaType, _xmlType);
    }
    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.EnumDeserializer(
            _javaType, _xmlType);
    }
    // Type metadata
    private static org.apache.axis.description.TypeDesc typeDesc =
        new org.apache.axis.description.TypeDesc(AppSourceSelector.class);

    static {
        typeDesc.setXmlType(new javax.xml.namespace.QName("com.*.*", "AppSourceSelector"));


    }
    /**
     * Return type metadata object
     */
    public static org.apache.axis.description.TypeDesc getTypeDesc() {
        return typeDesc;
    }

}

应用Entity.java

public class ApplicationEntity implements Serializable
{

    @XmlElement(name = "AppSource", required = true)
    @XmlSchemaType(name = "string")
    private com.*.*.AppSourceSelector appSource;

    // Type metadata
    private static org.apache.axis.description.TypeDesc typeDesc =
        new org.apache.axis.description.TypeDesc(ApplicationEntity.class, true);

    static {
        typeDesc.setXmlType(new javax.xml.namespace.QName("com.*.*", "ApplicationEntity"));

        org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();

        elemField.setFieldName("appSource");
        elemField.setXmlName(new javax.xml.namespace.QName("com.*.*", "AppSource"));
        elemField.setXmlType(new javax.xml.namespace.QName("com.*.*", "AppSourceSelector"));
        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);
    }

}

有人可以帮忙吗?

0 个答案:

没有答案