import junit.framework.TestCase; import org.apache.axis2.databinding.types.IDRef; import org.apache.axis2.databinding.types.Id; import org.appcelerator.axis2.AxisUtil; import axis.query.QueryServiceStub.ItemTemplateType; import axis.query.QueryServiceStub.Query; import axis.query.QueryServiceStub.QueryType; import axis.query.QueryServiceStub.RelationshipRefType; import axis.query.QueryServiceStub.RelationshipTemplateType; public class SerializationTest extends TestCase { public void testRequestJson() { Query param = createQuery(); System.out.println(AxisUtil.toJSONObject(param).toString()); } public static Query createQuery() { QueryType querytype = createQueryType(); Query query = new Query(); query.setQuery(querytype); return query; } public static QueryType createQueryType() { ItemTemplateType itemTemplateType1 = new ItemTemplateType(); itemTemplateType1.setId(new Id("ALL_CI1s")); ItemTemplateType itemTemplateType2 = new ItemTemplateType(); itemTemplateType2.setId(new Id("ALL_CI2s")); QueryType queryType = new QueryType(); queryType.setItemTemplate(new ItemTemplateType[] { itemTemplateType1, itemTemplateType2 }); RelationshipTemplateType relationshipTemplate = new RelationshipTemplateType(); relationshipTemplate.setId(new Id("ALL_Relations")); IDRef ref1 = new IDRef("ALL_CI1s"); RelationshipRefType sourceTemplate = new RelationshipRefType(); sourceTemplate.setMaximum(22); sourceTemplate.setRef(ref1); relationshipTemplate.setSourceTemplate(sourceTemplate); IDRef ref2 = new IDRef("ALL_CI2s"); RelationshipRefType targetTemplate = new RelationshipRefType(); targetTemplate.setRef(ref2); relationshipTemplate.setTargetTemplate(targetTemplate); queryType.setRelationshipTemplate(new RelationshipTemplateType[] { relationshipTemplate }); return queryType; } }