2013年7月29日星期一

android how to parse the webservice pass over the list?

 
SoapObject result = (SoapObject) envelope.bodyIn; / / Detail = (SoapObject) result.getProperty (METHOD_NAME); Log.d (LogInfo, result.toString ()); <>
print result.toString () is getVersion1Response {out = anyType {IPRFolder = anyType {folderName = ipr_txt; folderVersion = 1;};};}
pass over the List is List there are two variables folderName, folderVersion
------ Solution ----------------- ---------------------------
certainly want to have an object with which correspond
------ Solution --------------------------------------------
 SoapObject soapObject = (SoapObject) envelope.getResponse (); / / If the acquisition is a collection of the following operation on it < br /> if (soapObject.getName () == "anyType") 
{ / / Iterate a collection of Web Service to get
for (int i = 0; i / / Get a single data
SoapObject soapChilds = (SoapObject) soapObject.getProperty (i); / / The data for a single re-iterate, each row of data it read out
for (int k = 0; k { PropertyInfo propertyInfo = new PropertyInfo (); soapChilds.getPropertyInfo (k, propertyInfo); / / Get all the properties of the entity class
Field [] field = m.getClass (). getDeclaredFields (); / / Loop through all the attributes
for (int j = 0 ; j String name = field [j]. getName (); / / The name of each attribute with the Web Service returns the k rows contrast
String ppinfoname = propertyInfo.getName (). toLowerCase (); if (ppinfoname.equals (name.toLowerCase ()))
{ / / Call a way I do not understand, to an entity class assignment, do not understand the specific meaning of the data that's it.
GetSetManager. setFieldValue (m, name, field [j]. getType (),
soapChilds. getProperty (propertyInfo.getName ()). toString ()); }
}
}
list.add (m); }
} <>
------ Solution - -------------------------------------------
 public static void setFieldValue (Object target, String fname, Class ftype, Object fvalue) {/ / set field values ??such as: username field, setUsername ( String username) 
if (target == null | | Fname == null | | "". Equals (fname) | | (Fvalue! = Null && ;! ftype.isAssignableFrom (fvalue.getClass ()))) {/ / If the types do not match, exit return; } Class clazz = target.getClass (); try {/ / first pass setXxx () method to set the class attribute value
String methodname = "set" + Character.toUpperCase (fname.charAt (0)) + fname . substring (1); System.out.println (methodname); Method method = clazz.getDeclaredMethod (methodname, ftype); / / get methods defined
if (! Modifier.isPublic (method.getModifiers ())) {/ / There are ways to set permissions non
method.setAccessible (true); } method.invoke (target, fvalue); / / execute method callback
} Catch (Exception me) {/ / if the set method does not exist, then set the class attribute values ??directly
try { Field field = clazz.getDeclaredField (fname); / / Get the definition of class properties
if (! Modifier.isPublic (field.getModifiers ())) { / / set the class attribute permissions unshared
field.setAccessible (true); ; } field.set (target, fvalue); / / set the class attribute value
} Catch (Exception fe) { } } } <>
------ Solution ----------------------- ---------------------
understanding is: pass over a collection of objects, and then you pass traversal SoapObject
out = anyType {IPRFolder = anyType {folderName = ipr_txt; folderVersion = 1;
obtain one set of an object PropertyInfo
by traversing an object attribute corresponding to assign java object, and finally get a collection
------ For reference only --------------- ------------------------

Please also specific.
------ For reference only -------------------------------------- -
This reply was moderator deleted at 2011-04-13 09:48:20 <>
------ For reference only ---------------------------------- -----
do not know how, tomorrow morning to verify!
------ For reference only -------------------------------------- -
I also encountered the same problem,
The result returned is: anyType {DtoTitle = anyType {NewsId = 1180; NewsTitle = Wuling District Local Taxation Bureau to celebrate August Army;}; DtoTitle = anyType {NewsId = 1178; NewsTitle = RC strengthen part-time ombudsman function;};}
in the end is how to resolve the client or server problem? ?
convenient, hope that the landlord can give an answer? The primary problem? ? qq: 361820238@qq.com
------ For reference only ----------------------------- ----------
The reply deleted by an administrator at 2013-07-06 14:26:07 <>
------ For reference only ---------------------------------- -----
I like: anyType {string = 660a3c70-25cd-42d7-8d27-a12400ec914c; string = average user; string = 0; string = 46c245c4-0545-448d-a936 -a171010a1adf; string = brand stores; string = 0; string = f92868ac-73d6-468e-82a5-a171010a2473; string = manufacturer; string = 0; string = 9af7e949-345a -4b94-8ca8-a171010a4043; string = building materials market; string = 0; string = 8c88b47b-689f-422d-8a82-a171010a492e; string = decoration company; string = 0; string = 700042a0-4b56-4b76-a5dc-a171010a5cb7; string = design company; string = 0; string = baebe35b-86b6-4523-90ff-a171010a6320; string = logistics company; string = 0 ; string = da8eab75-3f51-42e0-b6d3-a17200aea69f; string = Industry Association; string = 0; string = 78ca0de0-90ca-49df-b0bc-a19400f1f9ed; string = developer; ; string = 0;}
All information on how to deal with a Lane?

1 条评论:

  1. f you don't understand my answer, don't ignore it, ask a question.

    回复删除