package Telephone.test;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
import org.xmlpull.v1.XmlPullParserException;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
public class TelephoneActivity extends Activity {
/ ** Called when the activity is first created. * /
private EditText usernameEditText;
private TextView resultView;
private Button queryButton;
public void onCreate (Bundle savedInstanceState) {
super.onCreate (savedInstanceState);
setContentView (R.layout.main);
usernameEditText = (EditText) findViewById (R.id.phone_sec);
resultView = (TextView) findViewById (R.id.result_text);
queryButton = (Button) findViewById (R.id.query_btn);
queryButton.setOnClickListener (new OnClickListener () {
public void onClick (View v) {
String username = usernameEditText.getText () toString () trim ();..
try {
List> newsdata = getSpecCatNews (username);
SimpleAdapter newslistAdapter = new SimpleAdapter (TelephoneActivity.this, newsdata, R.layout.main, new String [] {"task_title"}, new int [] {R.id.task_title});
ListView newslist = (ListView) findViewById (R.id.listview);
newslist.setAdapter (newslistAdapter);
} Catch (IOException e1) {
/ / TODO Auto-generated catch block6
e1.printStackTrace ();
} Catch (XmlPullParserException e1) {
/ / TODO Auto-generated catch block
e1.printStackTrace ();
}
/ / Try {
/ / GetRemoteInfo (username);
/ /} Catch (IOException e) {
/ / TODO Auto-generated catch block
/ / E.printStackTrace ();
/ /} Catch (XmlPullParserException e) {
/ / TODO Auto-generated catch block
/ / E.printStackTrace ();
/ /}
}
});
}
private List> getSpecCatNews (String username) throws IOException, XmlPullParserException {
List> newslist = new ArrayList > ();
/ / Namespace
String nameSpace = "http://tempuri.org/";
/ / Method name
callString methodName = "GetTaskUserName";
/ / EndPoint
String endPoint = "http://192.168.0.100:8081/WebService.asmx";
/ / SOAP Action
String soapAction = "http://tempuri.org/GetTaskUserName";
/ / Specify WebService namespace and method name to call
SoapObject rpc = new SoapObject (nameSpace, methodName);
/ / Set the required incoming call WebService interface requires two parameters mobileCode, userId
rpc.addProperty ("username", username);
/ / Generate method call WebService SOAP request message, and specify the version of SOAP
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope (SoapEnvelope.VER12);
envelope.bodyOut = rpc;
/ / Set whether the call is dotNet development WebService
envelope.dotNet = true;
envelope.setOutputSoapObject (rpc);
HttpTransportSE transport = new HttpTransportSE (endPoint);
transport.call (soapAction, envelope);
/ / Get the returned data
SoapObject object = (SoapObject) envelope.bodyIn;
/ / Get the results returned
/ / Get the return result
for (int i = 0; iSoapObject soapChilds = (SoapObject) object.getProperty (i);
HashMaphashMap = new HashMap ();
/ / List.add (soapChilds.getProperty ("price20GP") toString ().);
hashMap.put ("task_title", soapChilds.getProperty ("TaskTitle") toString ().);
newslist.add (hashMap);
}
return newslist;
}
}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Error prompt:

Reply:

Reply:
Do not sink paste ah. . . . . . . .
No comments:
Post a Comment