在android连接webservice的时候如何能给服务器传递参数&做出来不带参数的就可以访问webservice,但是如果是带参数的话就不行了,怎么也不能把参数传递出去,望做过的前辈给讲讲原理,呵呵……谢谢……

解决方案 »

  1.   


    你是用什么?用axis,根据url生成静态类,然后写客户端调用就行了。
      

  2.   

    我是用c#。net写的服务器,就是我随便传递给服务器一个参数  比如   字符串  “1”  然后对方可以接收就行,不知道有谁做过吗,呵呵……
      

  3.   

    lz是通过ksoap2方式连接webservice的吗?
      

  4.   

    我是把,那个转换成Base64的。
    而且Base64是要重写的。
    你在网上就可以找到
      

  5.   

    你是用// 第2步:设置WebService方法的参数
    rpc.addProperty("phoneno","13795443424");
    这种方式传的值吗?
      

  6.   

    把webservice包装成REST 方式调用。
      

  7.   

    为什么我的webservice端收不到android传递的参数啊,求高手指点,先谢过了!
      

  8.   

    package your.huoqushoujixinghao.namespace;import java.io.UnsupportedEncodingException;import android.app.Activity;
    import android.os.Bundle;
    import android.widget.Button;
    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    import android.widget.Toast;import org.ksoap2.SoapEnvelope;
    import org.ksoap2.serialization.SoapObject;
    import org.ksoap2.serialization.SoapSerializationEnvelope;
    import org.ksoap2.transport.HttpTransportSE;public class HuoqushoujixinghaoActivity extends Activity {
     private Button okButton;
     private EditText textview1; /** Called when the activity is first created. */
     @Override
     public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     setContentView(R.layout.main);     okButton = (Button) this.findViewById(R.id.button1);
      okButton.setOnClickListener(new Button.OnClickListener() {
       @Override
       public void onClick(View v) 
       {
       String city = "青岛";
       getWeather(city);
       }
      });
     } private static final String NAMESPACE = "http://WebXml.com.cn/";
     // WebService地址
     private static String URL = "http://www.webxml.com.cn/webservices/weatherwebservice.asmx"; private static final String METHOD_NAME = "getWeatherbyCityName";
     private static String SOAP_ACTION = "http://WebXml.com.cn/getWeatherbyCityName";
     private String weatherToday;
     private SoapObject detail; public void getWeather(String cityName) {
      try {
      
      
       textview1 = (EditText) this.findViewById(R.id.editText3);
       
       //这是soapobject 里面含有命名空间 和 函数名称
       SoapObject rpc = new SoapObject(NAMESPACE, METHOD_NAME);
       rpc.addProperty("theCityName", cityName);

       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
       envelope.bodyOut = rpc;
       envelope.dotNet = true;
       envelope.setOutputSoapObject(rpc);
       //将请求地址加上
       HttpTransportSE ht = new HttpTransportSE(URL);
       ht.debug = true;
       //这个就不太清楚了
       ht.call(SOAP_ACTION, envelope);
       //返回一个SoapObject
       detail = (SoapObject) envelope.getResponse();
       //Toast.makeText(this, detail.toString(), Toast.LENGTH_LONG).show();
       textview1.setText(detail.toString());
       return;
       
      } catch (Exception e) 
      {
      e.printStackTrace();
      }
     }
    }
      

  9.   

    这个我已经测试通过 绝对好用  ,主要是在  xml  页面定义一个按钮  和一个编辑框   ,上面代码改的主要是包名和类名.上面的代码就可以用了.
      

  10.   

    文件解决参考
    http://www.hicrm.com.cn/App/Component/InfoMgr/InfoPreview.aspx?idsType=idsView&idsID=20121110162334069529