复杂的类型我们这里就是像Map,List等的集合类型,或Person这种我们自己定义的Pojo类。
这些类型在我们的web服务端进行了相应的使用。
例如在和别的公司进行调试的时候,他们用的xfire做的webservice的服务端,好了后会给你个wsdl
// Person p = new Person();
// p.setAge(20);
// //注意namespace要和wsdl中的一致,否则不能辨认出来
// p.setName(new JAXBElement<String>(new
// QName("http://pojo","name"),String.class,"lAmbert"));
@XmlAccessorType(XmlAccesstype.FIELD)
@XmlType(name = "Person",propOrder = {
"age",
"name"
})
public class Person {
protected Integer age;
@XmlElementRef(name = "name",namespace = "http://pojo",type = JAXBElement.class)
protected JAXBElement<String> name;
/**
* Gets the value of the age property.
*
* @return
* possible object is
* {@link Integer }
*
*/
public Integer getAge() {
return age;
}
/**
* Sets the value of the age property.
*
* @param value
* allowed object is
* {@link Integer }
*
*/
public void setAge(Integer value) {
this.age = value;
}
/**
* Gets the value of the name property.
*
* @return
* possible object is
* {@link JAXBElement }{@code <}{@link String }{@code >}
*
*/
public JAXBElement<String> getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is
* {@link JAXBElement }{@code <}{@link String }{@code >}
*
*/
public void setName(JAXBElement<String> value) {
this.name = ((JAXBElement<String> ) value);
}
}
2 Map类型的。
这时候会自动生成一个AnyType2AnyTypeMap.java的类,接口中的调用参数也是AnyType2AnyTypeMap这种类型的。
我们要制造了.
ObjectFactory fac = new ObjectFactory(); //在AnyType2AnyTypeMap的同个包中就有
AnyType2AnyTypeMap at2am = fac.createAnyType2AnyTypeMap();
List<AnyType2AnyTypeMap.Entry> list = at2am.getEntry();
//对于传进来的map
Map map = new HashMap();
map.put("name","rose");
map.put("age","23");
Iterator<Map.Entry<String,String>> it = map.entrySet().iterator();
while(it.hasNext()){
Map.Entry<String,String> entry = it.next();
AnyType2AnyTypeMap.Entry ey = fac.createAnyType2AnyTypeMapEntry();
ey.setKey(entry.getKey());
ey.setValue(entry.getValue());
list.add(ey);
}
spt.printMap(at2am); //接口的调用
3 List类型
同2 中的差不多也是列用ObjectFactory
arrayofstring bookNames = fac.createarrayofstring();
List<String> bookNameList = bookNames.getString();
bookNameList.add("《社会心理学》");
bookNameList.add("《心理学与生活》");
.......//调用
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。