Took a few days and finally connected to the database, but a new problem has emerged it! Get out of the data contained anyType, String type as shown:

How I parse out?

<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
public static CenterInfo [] getWorkOn (SoapObject obj) {
CenterInfo [] info = null;
try {
if (obj.getPropertyCount ()> 1) {/ / a central information
int len = obj.getPropertyCount () - 1;
info = new CenterInfo [len];
for (int i = 0; i
String idStr = child.getPropertyAsString (0);
String content = child.getPropertyAsString (1);
String sender = child.getPropertyAsString (2);
String typeStr = child.getPropertyAsString (3);
String uId = child.getPropertyAsString (4);
String time = child.getPropertyAsString (5) ;/ / Time
long id = Long.parseLong (idStr);
int type = Integer.parseInt (typeStr);
info [i] = new CenterInfo (id, content, sender, type, uId, time);
}
}
} Catch (Exception e) {
e.printStackTrace ();
}
return info;
}
Reply:
How does this CenterInfo [] is what ah? Novice seeking advice do not understand, there getPropertyCount () is what? These are how to use?

Reply:
This error may be we do not quite understand, especially posted code, seeking advice:
MainActivity:
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.activity_main);
searchs = (Button) findViewById (R.id.search);
results = (TextView) findViewById (R.id.result);
searchs.setOnClickListener (new View.OnClickListener () {
@ Override
public void onClick (View v) {
String wsdUrl = "http://192.168.1.195:88/service1.asmx";
String method = "SelectAll";
Object result = SOAPUtil.doTransport (wsdUrl, method);
results.setText (result.toString ());
}
});
}
SoapUtil:
public static Object doTransport (final String wsdUrl, final String webMethod) {
String nameSpace = "http://tempuri.org/";
SoapObject soapObject = new SoapObject (nameSpace, webMethod);
/ / SoapObject.addProperty (propertyInfo)
System.out.println ();
SoapSerializationEnvelope soapSerializationEnvelope = new SoapSerializationEnvelope (
SoapEnvelope.VER11);
soapSerializationEnvelope.bodyOut = soapObject;
soapSerializationEnvelope.dotNet = true;
soapSerializationEnvelope.setOutputSoapObject (soapObject);
HttpTransportSE httpTransportSE = new HttpTransportSE (wsdUrl);
String SOAP_ACTION = "http://tempuri.org/" + webMethod;
System.out.println (SOAP_ACTION);
try {
httpTransportSE.call (SOAP_ACTION, soapSerializationEnvelope);
System.out.println ("call end");
System.out.println (soapSerializationEnvelope.getResponse ());
if (soapSerializationEnvelope.getResponse ()! = null) {
SoapObject result = (SoapObject) soapSerializationEnvelope
. GetResponse ();
System.out.println (result);
return result;
}
} Catch (IOException e) {
System.out.println ("IOException");
e.printStackTrace ();
} Catch (XmlPullParserException e) {
e.printStackTrace ();
}
return null;
Is it because I put all the data in a textview toString inside out? I how to put the data in the listview and display only the data do not show others?
Reply:
/ / Convert the SoapObject (CenterInfo) an array of objects
public static CenterInfo [] getWorkOn (SoapObject obj) {
/ / Define array
CenterInfo [] info = null;
try {
/ / If the received information
if (obj.getPropertyCount ()> 1) {/ / a central information
/ / Calculate the maximum array subscript
int len = obj.getPropertyCount () - 1;
/ / Initialize the array object is to open up an array of storage space
info = new CenterInfo [len];
/ / Iterate analytical SoapObject
for (int i = 0; i
SoapObject child = (SoapObject) obj.getProperty (i + 1);
/ / Values
String idStr = child.getPropertyAsString (0);
String content = child.getPropertyAsString (1);
String sender = child.getPropertyAsString (2);
String typeStr = child.getPropertyAsString (3);
String uId = child.getPropertyAsString (4);
String time = child.getPropertyAsString (5) ;/ / Time
long id = Long.parseLong (idStr);
int type = Integer.parseInt (typeStr);
/ / Packaged as demand object (CenterInfo), into an array of resources
info [i] = new CenterInfo (id, content, sender, type, uId, time);
}
}
} Catch (Exception e) {
e.printStackTrace ();
}
return info;
}
Reply:
LZ, this object is the need to resolve the drops, not directly toString ...... Do you Know?
Reply:
Aware of the need to resolve ah, someone said to resolve soapObject, some say parse json, very puzzled not understand ......
In the end resolve what, how to resolve?

Reply:
Parsing the object you get what you get, ah resolve even on ah? Did you get the SoapObject to turn into other types of reuse json parsing? ? ?
Reply:
The results still suffocating! How to make the data corresponding to a strip show? Why take the data front and anyType ah damn String
Reply:
It depends on the how to write http://192.168.1.195:88/service1.asmx this webservice return data definitions
Reply:
A better approach is: a good return on both sides to define the data format, preferably json format, which can be google can also be apache, and analytical tools so that you can be here when parsing apache provided by google or , very convenient.
If you give directly to parse the string, then write their own methods to deal with. . . . I can not think of other ways
Reply:
Thank you for helping, finally finally solved the problem: parsing soapObject specifically wrote a class to complete the goal, the main method:
public static ArrayList
Reply:
Your method is very good, I ask you how the query results are displayed in? Do with the Listview
Reply:
Landlord you and I encountered the same problem you can send a demo to me it 1322566179@qq.com good
No comments:
Post a Comment