解决方案 »

  1.   

    还是把代码贴到这来吧
    .NET的 webservice  端代码:   用 本机的IIS  发布的   (浏览器访问  能正确 调用webservice )
    using System;
    using System.Web;
    using System.Web.Services;
    using System.Web.Services.Protocols;
    using System.Data.SqlClient;
    using System.Data;//[WebService(Namespace = "http://tempuri.org/")]
    //[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)][WebService(Namespace = "http://192.168.1.102:8086/")]
    [System.Web.Services.Protocols.SoapRpcService]public class Service : System.Web.Services.WebService
    {
        public Service () {        //如果使用设计的组件,请取消注释以下行 
            //InitializeComponent(); 
        }
      
        [WebMethod(Description = "数据操作")]      public string  Hello(string  strName)
           {
               return  strName;
           }        
    }
    Android端代码:
    package weather.android;import java.io.IOException;
    import java.io.UnsupportedEncodingException;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.Map;
    import java.util.Set;import org.ksoap2.SoapEnvelope;
    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 weather.android.R.string;import android.R.bool;
    import android.app.Activity;
    import android.content.Context;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.Toast;public class AndroidweatherActivity extends Activity {
        /** Called when the activity is first created. */
       
        private Button okButton;
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            okButton = (Button) this.findViewById(R.id.button1);
            okButton.setOnClickListener(new OnClickListener(){ public void onClick(View v) {
    // TODO Auto-generated method stub
    String cityname="sky";

    Hello(cityname);
    }
            }); 
        }
        

    public static String Url = "http://192.168.1.102:8086/Service.asmx";
    public static String NameSpace = "http://192.168.1.102:8086/";//这里就是基本那个空间名,实际用地时候看你的.NET部分
    public static String MethodName ="";
    public static String SoapAction = NameSpace + MethodName;


    public static String Hello(String strName)
    {
      MethodName ="Hello";
      SoapAction = NameSpace + MethodName;
     
      
      try{
       
       SoapObject request = new SoapObject(NameSpace, MethodName); 
       request.addProperty("strName",strName);
       SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11); //必须用VER11才能调用到.net的 ws
       envelope.dotNet = true; 
       envelope.setOutputSoapObject(request);
       HttpTransportSE ht = new HttpTransportSE(Url); 
       
       ht.call(SoapAction, envelope); 
       if(envelope.getResponse()!=null)
       {  
       
        System.out.println("detail1  "+envelope.getResponse() );
       }
         else
       {
       System.out.println("detail2  " );
       
       }
       
      }
      catch (Exception e) {    System.out.println("detail3  " + e);
      
      }
    return strName; 
    } }

    需解决问题:
    ——————————————————————
    整个Android 程序 运行后   总显示 结果 为    System.out.println("detail2 " );      即   envelope.getResponse()得到的值为null        如何android端才能  正确 调用 webservice     (向webservice    发送参数)求大牛门帮帮忙   多谢啦 !!
      

  2.   

    http://blog.csdn.net/suntanyong88/article/details/7694965给你看个 远程调用的 ,手机归属地查询简化版的
      

  3.   


    web调用 我也会     windows mobil 的 调用webservices  也做过   ,
    都还算顺利
    就这个 Android 的  折腾坏我了    
    一定要解决   还是要 谢谢  2  楼    的回复