http://code.google.com/p/ksoap2-android/

解决方案 »

  1.   

    这个工具是给android使用,专门用于调用WS接口的,使用很方便,网上也有大量使用的例子
      

  2.   

    去网上下载这个jar包:ksoap2-android-assembly-2.4-jar-with-dependencies.jar
    使用方法如下:public class TestWebService extends Activity {
        
    private static String NameSpace="http://tempuri.org/";
    private static String u="http://10.8.8.70:808";//请更换成你要访问的服务器地址
    private static String webService="/webService/WebService.asmx";//webService目录
    private static String MethodName="HelloWorld2";//要调用的webService方法
    private static String soapAction=NameSpace+MethodName;
    private static String url=u+webService;

    private TextView tv;

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
        
            tv=(TextView)findViewById(R.id.tv);
            tv.setText(ws());
        }
        //webService操作要访问网络,所以最好是使用线程来做,这里只是示例,所以就不考虑了
        private String ws(){
         String result="";
         try{
         SoapObject request=new SoapObject(NameSpace,MethodName);//NameSpace
         //webService方法中的参数,这个根据你的webservice来,可以没有。
         //但请注意,参数名称和参数类型客户端和服务端一定要一致,否则将可能获取不到你想要的
         //request.addProperty("x",5);
         //request.addProperty("y", 6);
        
         SoapSerializationEnvelope envelope=new SoapSerializationEnvelope(
         SoapEnvelope.VER11);
        
         envelope.dotNet=true;
        
         envelope.setOutputSoapObject(request);
        
         HttpTransportSE ht=new HttpTransportSE(url);
        
         ht.call(soapAction, envelope);
        
         if(envelope.getResponse()!=null){
         SoapPrimitive response=(SoapPrimitive)envelope.getResponse();
         result=response.toString();//这里获得了webService的返回值
         }
        
         }catch(Exception e){
         result=e.getMessage();
         }
         return result;
        }
    }
      

  3.   

    jdk1.6以上支持命令行获取服务的代码,wsinport xxxxx,把相关代码搞到手,具体使用方法你可以查,不需要第三方jar
      

  4.   

    老外有写了这样的生成工具,网址是:
    http://code.google.com/p/android-ws-client/downloads/list
    可以一起研究一下,我碰到了跟你同样的问题。
      

  5.   

    老外写了一个Android端上能生成WebService代理类的工具,
    谁有兴趣一起研究一下,老外的网址是:
    http://code.google.com/p/android-ws-client/