I fired up my WebServicesExplorer in my Eclipse recently and I just realized that the xs:element names generated by JAXB are not so verbose. Here is one of the sequences:
<xs:sequence>
<xs:element minOccurs="0" name="arg0" type="xs:string" />
<xs:element minOccurs="0" name="arg1" type="xs:string" />
<xs:element name="arg2" type="xs:int" />
</xs:sequence>
generated from this file:
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class User {
private String firstName;
private String lastName;
private int age;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
I’m not a JAXB expert yet, so I was wondering whether I can change those arg* named elements into something sensible, like in the POJO class?
You do not mention what web service framework you are using but the behaviour sounds similar to the JAX-WS specs, e.g. The parts in my generated wsdl have names of the form “arg0”, “arg1”, … Why don’t the parts (and Java generated from them) use the nice parameter names I typed into the interface definition?
You could try adding an XmlElement annotation to each field and specify a name, but are you sure this is caused by JAXB? If I run schemagen with your POJO code this is what I get (the names are picked up correctly):
Based on your comment, if you “force” your POJO to the following code, do you still get complaints about duplicate names?