package com.google.Highspeed;import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast;public class Fuwuqu extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fuwuqu);
RGDemo(); }
RadioGroup rg;
RadioButton b1;
RadioButton b2;
private EditText p;
private TextView t;
public void RGDemo(){
rg=(RadioGroup)findViewById(R.id.radioGroup1);
b1=(RadioButton)findViewById(R.id.radio0);
b2=(RadioButton)findViewById(R.id.radio1);
p=(EditText)findViewById(R.id.editText1);
t=(TextView)findViewById(R.id.textView2);
Button clr=(Button)findViewById(R.id.button1);
clr.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(b1.isChecked()){
Get(p.getText().toString(),"青岛方向");
}
if(b2.isChecked()){
Get(p.getText().toString(),"济南方向");
}
}
});
rg.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
if(checkedId==b1.getId()){
Toast.makeText(Fuwuqu.this,"b1选中", Toast.LENGTH_LONG).show();
}
if(checkedId==b2.getId()){
Toast.makeText(Fuwuqu.this,"b2选中", Toast.LENGTH_LONG).show();
}
} });
}
private static final String WDSL_LINK = "http://localhost:8090/axis2/services/fuwuservice?wsdl";
private static final String NAME_SPACE = "http://service.hightway.com";//"http://land.com/";
private static final String METHOD_NAME = "check";
private void Get(String fuwu,String fang) {
try {
SoapObject request = new SoapObject(NAME_SPACE, METHOD_NAME);
// TODO Auto-generated method stub
request.addProperty("arg0",fuwu);
request.addProperty("arg1",fang); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = request;
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(WDSL_LINK);
ht.call("", envelope);
String ret = String.valueOf(envelope.getResponse());
t.setText(ret);
} catch (Exception ex) {
Log.d("my_webservcie_Error: "+ex.getMessage(), null); t.setText("连接失败");
}
}
}上面的代码有什么问题没有?我在android虚拟机上运行该程序点击按钮时提示程序强制关闭AndroidWeb服务
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapPrimitive;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast;public class Fuwuqu extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fuwuqu);
RGDemo(); }
RadioGroup rg;
RadioButton b1;
RadioButton b2;
private EditText p;
private TextView t;
public void RGDemo(){
rg=(RadioGroup)findViewById(R.id.radioGroup1);
b1=(RadioButton)findViewById(R.id.radio0);
b2=(RadioButton)findViewById(R.id.radio1);
p=(EditText)findViewById(R.id.editText1);
t=(TextView)findViewById(R.id.textView2);
Button clr=(Button)findViewById(R.id.button1);
clr.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(b1.isChecked()){
Get(p.getText().toString(),"青岛方向");
}
if(b2.isChecked()){
Get(p.getText().toString(),"济南方向");
}
}
});
rg.setOnCheckedChangeListener(new OnCheckedChangeListener(){
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
if(checkedId==b1.getId()){
Toast.makeText(Fuwuqu.this,"b1选中", Toast.LENGTH_LONG).show();
}
if(checkedId==b2.getId()){
Toast.makeText(Fuwuqu.this,"b2选中", Toast.LENGTH_LONG).show();
}
} });
}
private static final String WDSL_LINK = "http://localhost:8090/axis2/services/fuwuservice?wsdl";
private static final String NAME_SPACE = "http://service.hightway.com";//"http://land.com/";
private static final String METHOD_NAME = "check";
private void Get(String fuwu,String fang) {
try {
SoapObject request = new SoapObject(NAME_SPACE, METHOD_NAME);
// TODO Auto-generated method stub
request.addProperty("arg0",fuwu);
request.addProperty("arg1",fang); SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.bodyOut = request;
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE ht = new HttpTransportSE(WDSL_LINK);
ht.call("", envelope);
String ret = String.valueOf(envelope.getResponse());
t.setText(ret);
} catch (Exception ex) {
Log.d("my_webservcie_Error: "+ex.getMessage(), null); t.setText("连接失败");
}
}
}上面的代码有什么问题没有?我在android虚拟机上运行该程序点击按钮时提示程序强制关闭AndroidWeb服务
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货