对应的WSDL

<?xml version="1.0"?>

<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://lee/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/wsdl/soap/http" targetNamespace="http://lee/" name="firstWs"><wsdl:types><xs:schema xmlns:tns="http://lee/" targetNamespace="http://lee/" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="unqualified" attributeFormDefault="unqualified"><xs:element name="getUserList" type="tns:getUserList"/><xs:element name="getUserListResponse" type="tns:getUserListResponse"/><xs:complexType name="getUserList"><xs:sequence><xs:element name="arg0" type="xs:string" minOccurs="0"/></xs:sequence></xs:complexType><xs:complexType name="getUserListResponse"><xs:sequence><xs:element name="return" type="tns:user" minOccurs="0" maxOccurs="unbounded"/></xs:sequence></xs:complexType><xs:complexType name="user"><xs:sequence><xs:element name="gender" type="xs:string" minOccurs="0"/><xs:element name="height" type="xs:double"/><xs:element name="id" type="xs:int" minOccurs="0"/><xs:element name="name" type="xs:string" minOccurs="0"/></xs:sequence></xs:complexType></xs:schema></wsdl:types><wsdl:message name="getUserListResponse"><wsdl:part name="parameters" element="tns:getUserListResponse"></wsdl:part></wsdl:message><wsdl:message name="getUserList"><wsdl:part name="parameters" element="tns:getUserList"></wsdl:part></wsdl:message><wsdl:portType name="FirstWs"><wsdl:operation name="getUserList"><wsdl:input name="getUserList" message="tns:getUserList"></wsdl:input><wsdl:output name="getUserListResponse" message="tns:getUserListResponse"></wsdl:output></wsdl:operation></wsdl:portType><wsdl:binding name="firstWsSoapBinding" type="tns:FirstWs"><soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/><wsdl:operation name="getUserList"><soap:operation style="document" soapAction=""/><wsdl:input name="getUserList"><soap:body use="literal"/></wsdl:input><wsdl:output name="getUserListResponse"><soap:body use="literal"/></wsdl:output></wsdl:operation></wsdl:binding><wsdl:service name="firstWs"><wsdl:port name="FirstWsImplPort" binding="tns:firstWsSoapBinding"><soap:address location="http://192.168.1.101:8080/crazyit"/></wsdl:port></wsdl:service></wsdl:definitions>

对应android 部分代码

@SuppressLint("NewApi")
public class MainActivity extends Activity {
final static String SERVICE_NS="http://lee/";
final static String SERVICE_URL="http://192.168.1.101:8080/crazyit";
private EditText txt1;
private EditText txt2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectDiskReads().detectDiskWrites().detectNetwork().penaltyLog().build());
StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectLeakedSqlLiteObjects().detectLeakedClosableObjects().penaltyLog().penaltyDeath().build());
txt1=(EditText)findViewById(R.id.txt1);
txt2=(EditText)findViewById(R.id.txt2);
//调用的方法
String methodName="getUserList";
//创建HttpTransportSE传输对象
HttpTransportSE ht=new HttpTransportSE(SERVICE_URL);
ht.debug=true;
//使用SOAP1.1协议创建Envelop对象
SoapSerializationEnvelope envelop=new SoapSerializationEnvelope(SoapEnvelope.VER11);
//实例化SoapObject对象
SoapObject soapObject=new SoapObject(SERVICE_NS, methodName);
soapObject.addProperty("arg0","客户端参数:");
//将soapObject对象设置为SoapSerializationEnvelope对象传出SOAP消息
envelop.bodyOut=soapObject;
//调用Web Service
try {
ht.call(null, envelop);
if(envelop.getResponse()!=null){
//获取服务器响应返回的SOAP消息
SoapObject result=(SoapObject)envelop.bodyIn;
//接下来从SoapObject对象中解析响应数据的过程
SoapObject detail1=(SoapObject)result.getProperty(0);
SoapObject detail2=(SoapObject)result.getProperty(1);
StringBuilder personl=new StringBuilder();
personl.append("用户名:");
personl.append(detail1.getProperty(3));
personl.append("\n密码");
personl.append(detail1.getProperty(0));
personl.append("\n身高");
personl.append(detail1.getProperty(1));
txt1.setText(personl.toString());

StringBuilder personl2=new StringBuilder();
personl2.append("用户名:");
personl2.append(detail2.getProperty(3));
personl2.append("\n密码");
personl2.append(detail2.getProperty(0));
personl2.append("\n身高");
personl2.append(detail2.getProperty(1));
txt2.setText(personl2.toString());
}
} catch (IOException e) {
e.printStackTrace();
} catch (XmlPullParserException e) {
e.printStackTrace();
}
}

更多相关文章

  1. Android 4.2 webview注入js对象时需要注意的问题
  2. android基础学习--->Android SharedPreferences存储对象和图片(An
  3. android 使用SharedPreferences保存对象
  4. Android 内功心法(番外)——写在设计模式前,面对对象编程基础
  5. Android 使用Parcelable传递对象
  6. android webview 添加内置对象
  7. 在android中创建包含对象数组对象List 的Parcelable

随机推荐

  1. GIT生成ssh秘钥windows
  2. GIT生成ssh秘钥linux
  3. PHP使用SW-X框架的Redis-UML组件,对用户信
  4. Docker部署homeassitant
  5. 微信点餐系统源码|微信点餐小程序
  6. ModStartBlog v5.0.0 发布 全新架构系统,
  7. Android的UI学习
  8. android image 压缩和解压 unyaffs与mkya
  9. Android(安卓)APK安装过程及原理详解
  10. Android学习——基础组件