Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/367.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何设置wsimport创建的类中的多个实例变量?_Java_Jax Ws - Fatal编程技术网

Java 如何设置wsimport创建的类中的多个实例变量?

Java 如何设置wsimport创建的类中的多个实例变量?,java,jax-ws,Java,Jax Ws,我正在编写一个基于SOAP的客户端,它将更新数据库中的字段。java wsimport实用程序创建的一个类包含一个表的表示,该表中的每个字段都是受保护的实例变量。例: public class CustomObject1Data { @XmlElement(name = "ModifiedDate") @XmlSchemaType(name = "dateTime") protected XMLGregorianCalendar modifiedDate; @XmlElement(name =

我正在编写一个基于SOAP的客户端,它将更新数据库中的字段。java wsimport实用程序创建的一个类包含一个表的表示,该表中的每个字段都是受保护的实例变量。例:

public class CustomObject1Data {

@XmlElement(name = "ModifiedDate")
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar modifiedDate;
@XmlElement(name = "CreatedDate")
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar createdDate;
@XmlElement(name = "ModifiedById")
protected String modifiedById;
@XmlElement(name = "CreatedById")
protected String createdById;
@XmlElement(name = "ModId")
protected Integer modId;
@XmlElement(name = "Id")
protected String id;
@XmlElement(name = "CustomInteger5")
protected Integer customInteger5;
@XmlElement(name = "CustomInteger6")
protected Integer customInteger6;
.... 100+ more
用户界面将为这些字段提供友好的名称。他们熟悉的名称,因为它们是数据库中该记录的字段名。在幕后,UI将把UI字段名映射到XML名称。如果UI向我发送这样的查询字符串,
“CustomInteger5=somenewvalue”
,我如何设置该类成员

@XmlElement(name = "CustomInteger5")   
    protected Integer customInteger5;
我知道我可以有一堆if语句,比如:

if(requestStr.fieldName.equals("CustomInteger5"){   
      setCustomInteger5(rquestStr.value);   
}

这将是如此多的工作,虽然!如果以字符串形式提供xml名称,是否可以动态设置这些类成员


谢谢。

可能有更好的方法来完成我想要的,但是我能够使用Java反射API完成我需要的。如果有人有更好的解决方案,我是否仍有兴趣了解它?这是我学习反思的教程