Text ビューの Java コードと石鹸があります。
しかし、私はListViewが欲しいです。Android で SOAP リストを解析する方法。
SOAP 1.1 のリクエストとレスポンス
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorldResponse xmlns="http://tempuri.org/">
<HelloWorldResult>
<FormModel>
<Text1>string</Text1>
<Text2>string</Text2>
<Text3>string</Text3>
</FormModel>
<FormModel>
<Text1>string</Text1>
<Text2>string</Text2>
<Text3>string</Text3>
</FormModel>
</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>
オンライン Web サービスに接続しています。Ksoap2 を使用して xml を解析する方法を教えてください。
データをリストに表示するだけのように、石鹸を解析します。
メール.java
public class Main extends Activity {
private static String SOAP_ACTION = "http://tempuri.org/HelloWorld";
private static String NAMESPACE = "http://tempuri.org/";
private static String METHOD_NAME = "HelloWorld";
private static String URL = "http://sygnetinfosol.com/webservice.asmx?WSDL";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//Initialize soap request + add parameters
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.setOutputSoapObject(request);
// Make the soap call.
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
//this is the actual part that will call the webservice
androidHttpTransport.call(SOAP_ACTION, envelope);
} catch (Exception e) {
e.printStackTrace();
}
// Get the SoapResult from the envelope body.
SoapObject result = (SoapObject)envelope.bodyIn;
if(result != null){
TextView t = (TextView)this.findViewById(R.id.resultbox);
t.setText("SOAP response:\n\n" + result.getProperty(0).toString());
}
}
}
LogCat
03-13 06:50:57.077: I/Choreographer(2933): Skipped 114 frames! The application may be doing too much work on its main thread.
03-13 06:50:57.669: I/Choreographer(2933): Skipped 82 frames! The application may be doing too much work on its main thread.
03-13 06:50:57.787: I/Choreographer(2933): Skipped 91 frames! The application may be doing too much work on its main thread.
03-13 07:16:37.837: E/Trace(3374): error opening trace file: No such file or directory (2)
03-13 07:16:39.008: I/System.out(3374): MY SOAP RESPONE ISanyType{FormModel=anyType{Text1=12.9174948; Text2=77.5989675; Text3=JayDeva Hospital,Karnataka,Bangalore,India; }; FormModel=anyType{Text1=12.9274529; Text2=77.590597; Text3=9th Block,Central Mall,Jayanagar,Karnataka,Bangalore,India; }; FormModel=anyType{Text1=12.9285212; Text2=77.5834339; Text3=Jayanagar 4th Block,Karnataka,Bangalore,India; }; FormModel=anyType{Text1=12.961085; Text2=77.60469269; Text3=BTM Layout,Richmod Towr,Karnataka,Bangalore,India; }; }
03-13 07:16:39.117: D/dalvikvm(3374): GC_CONCURRENT freed 177K, 11% free 2590K/2908K, paused 80ms+5ms, total 201ms
03-13 07:16:39.438: I/Choreographer(3374): Skipped 347 frames! The application may be doing too much work on its main thread.
03-13 07:16:39.458: D/gralloc_goldfish(3374): Emulator without GPU emulation detected.
03-13 07:16:39.638: I/Choreographer(3374): Skipped 44 frames! The application may be doing too much work on its main thread.
03-13 07:16:40.437: I/Choreographer(3374): Skipped 74 frames! The application may be doing too much work on its main thread.