• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the XML Schema declaration for java.util.List

 
Bitan Biswas
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm defining a xml schema to generate a wsdl. for that i need to create such a schema which should be similar to a java class.

My java class is

public class GetDesignationResponse {

private List<Designation> designation;

public List<Designation> getDesignation() {
return designation;
}

public void setDesignation(List<Designation> designation) {
this.designation = designation;
}
}



public class Designation {

private int desigId;
private String desigName;

// getters setters
}

my xml schema file is something like


<xs:element name="desigId" type="xs:int" />
<xs:element name="desigName" type="xs:string" />

<xs:element name="designation" tns:minOccurs="0" tns:maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element ref="tns:desigId" />
<xs:element ref="tns:desigName" />
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="getDesignationResponse">
<xs:complexType>
<xs:sequence>
<xs:element ref="tns:designation" />
</xs:sequence>
</xs:complexType>
</xs:element>

but when i generating the java file by "wsimport" from wsdl,
the GetDesignationResponse java file is not having the List<Designation> property rather Desingation property.

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"designation"
})
@XmlRootElement(name = "getDesignationResponse")
public class GetDesignationResponse {

@XmlElement(required = true)
protected Designation designation; // i want this to be like ---> protected List<Designation> designation;


public Designation getDesignation() {
return designation;
}

public void setDesignation(Designation value) {
this.designation = value;
}
}


can anybody tell me how to declare schema in xml similar to List<Object>?
 
K. Tsang
Bartender
Posts: 3508
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are in luck, there is a "list' data type in XML schema. here
 
Bitan Biswas
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, i have data type for list. but it is capable for java primitives only.. not for java objects. i have already tried that.
 
K. Tsang
Bartender
Posts: 3508
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then your Designation is definitely not a simple type. Have you try setting the itemType to your complex Designation type?

Edit: your Designation type can also be simpleType in xml. here shows an example.
 
g tsuji
Ranch Hand
Posts: 669
3
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Never come across minOccurs and maxOccurs attributes by chance having a definition in the namespace of prefix tns whatever it is - unless you tell us how they are defined. If they are attached to xs namespace, their occurrence in that position of xs:element is erroneous.

Most likely, you simply mean this.


Then you want a list of some kind.
 
Bitan Biswas
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks, g tsuji... it worked.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic