【Android SOAP】基于第三方开源项目ksoap-android

项目地址:http://code.google.com/p/ksoap2-android/

 

服务器端,参考:【Web Service】Apache Tuscany发布Web Service

 

准备工作:

下载JAR文件

地址:http://ksoap2-android.googlecode.com/svn/m2-repo/com/google/code/ksoap2-android/ksoap2-android-assembly/3.0.0-RC.4/ksoap2-android-assembly-3.0.0-RC.4-jar-with-dependencies.jar

添加至项目Build Path

 

示例:

try {
    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    request.addProperty("arg0", mName);
                
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);
                
    HttpTransportSE transport = new HttpTransportSE(URL);
    transport.call(SOAP_ACTION, envelope);
                
    SoapObject response = (SoapObject) envelope.bodyIn;
    String returnString = response.getPropertyAsString("return");
    if (returnString == null) {
        //TODO:
    } else {
        //TODO:
    }
} catch (Exception e) {
    e.printStackTrace();
    //TODO:
}

 

参考:http://code.google.com/p/ksoap2-android/wiki/CodingTipsAndTricks

 

 

posted on 2013-01-21 11:54  Anthony Li  阅读(2916)  评论(1编辑  收藏  举报

博客园博客已停止更新,博客地址:dyinigbleed.com