首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

android调用webservice时出现点有关问题

2013-06-19 
android调用webservice时出现点问题android调用webservice 选不同的单选框当点击查询按钮时应该显示的信息

android调用webservice时出现点问题
android调用webservice 选不同的单选框当点击查询按钮时应该显示的信息不一样,现在怎么显示的信息都一样。代码:
import java.io.IOException;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.SoapFault;
import org.ksoap2.serialization.MarshalBase64;
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 org.xmlpull.v1.XmlPullParserException;

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 URL= "http://10.0.2.2: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 static int i=0;
    SoapObject request = new SoapObject(NAME_SPACE, METHOD_NAME);

 
 private void Get(String fuwu,String fang) {
// TODO Auto-generated method stub
   PropertyInfo propInfo=new PropertyInfo();
 // propInfo.name="arg0"; 
  propInfo.type=PropertyInfo.STRING_CLASS;
  
  request.addProperty("arg0",fuwu);
  request.addProperty("arg1",fang);

  SoapSerializationEnvelope  envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); 
  
  envelope.setOutputSoapObject(request); 
 HttpTransportSE ht = new HttpTransportSE(URL);

  try {
  ht.call(null, envelope);
 
  Object soapObject = (Object) envelope.getResponse();  
 i++;
  
  t.setText(p.getText().toString()+i+soapObject.toString());
  } catch (SoapFault e) {  
                  e.printStackTrace();  
              } catch (IOException e) {  
                  e.printStackTrace();  
              } catch (XmlPullParserException e) {  
                  e.printStackTrace();  
              }  
          
 
//  } catch (Exception ex) {
 // Log.d("my_webservcie_Error: "+ex.getMessage(), null);

// t.setText("连接");
   
  

} Android Web服务
[解决办法]
1.先看你的webservice是不是能正确返回数据。
2.断点调试看你发出去的参数是否正确

热点排行