这是调用webService的具体方法

private final static String nameSpace="http://tempuri.org/";
private final static String url = "http://10.188.65.139/BizNavi_Link_Phone/Service.asmx?wsdl"; public static List<WaitModel> CallWebService1() {
// 调用webservice的具体方法
String nameSpace = "http://tempuri.org/";
String methodName = "queryProcXml1";
String soapAction = "http://tempuri.org/"+methodName;
String url = "http://10.188.65.139/BizNavi_Link_Phone/Service.asmx?wsdl";// 后面加不加那个?wsdl参数影响都不大 // 建立webservice连接对象
HttpTransportSE transport = new HttpTransportSE(url);
// transport.debug = false;// 是否是调试模式
transport.debug = true;// 是否是调试模式 // 设置连接参数
SoapObject soapObject = new SoapObject(nameSpace, methodName); String paraNames []={"@in_EMPLOYEE_ID1"};
String paraValues [] ={""}; soapObject.addProperty("procName", "AFI02_HOME_GET_WAITING");
soapObject.addProperty("ret", ); // 设置返回参数
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);// soap协议版本必须用SoapEnvelope.VER11(Soap V1.1)
envelope.dotNet = true;// 注意:这个属性是对dotnetwebservice协议的支持,如果dotnet的webservice
// 不指定rpc方式则用true否则要用false
envelope.bodyOut = soapObject;//千万注意!! envelope.setOutputSoapObject(soapObject);// 设置请求参数
try {
//ClientUtil.SetCertification();// 设置证书
transport.call(soapAction, envelope);
SoapObject sb=(SoapObject)envelope.bodyIn;
String ss= sb.getProperty().toString();
InputStream inputStream=new ByteArrayInputStream(ss.getBytes());
return DomWait.readXml(inputStream);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
} public static List<?> queryProcXml(String procName,Vector<String> paraNames,Vector<String> paraValues){
String methodName = "queryProcXml1";
String soapAction = "http://tempuri.org/"+methodName; // 建立webservice连接对象
HttpTransportSE transport = new HttpTransportSE(url);
// transport.debug = false;// 是否是调试模式
transport.debug = true;// 是否是调试模式 // 设置连接参数
SoapObject soapObject = new SoapObject(nameSpace, methodName); soapObject.addProperty("procName", "AFI02_HOME_GET_WAITING");
soapObject.addProperty("ret", ); // 设置返回参数
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);// soap协议版本必须用SoapEnvelope.VER11(Soap V1.1)
envelope.dotNet = true;// 注意:这个属性是对dotnetwebservice协议的支持,如果dotnet的webservice
// 不指定rpc方式则用true否则要用false
envelope.bodyOut = soapObject;//千万注意!! envelope.setOutputSoapObject(soapObject);// 设置请求参数
try {
//ClientUtil.SetCertification();// 设置证书
transport.call(soapAction, envelope);
SoapObject sb=(SoapObject)envelope.bodyIn;
String ss= sb.getProperty().toString();
InputStream inputStream=new ByteArrayInputStream(ss.getBytes());
return DomWait.readXml(inputStream);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}

很脑残的解析

public static List<WaitModel> readXml(InputStream inStream) throws Exception

    {
List<WaitModel> waitModels=new ArrayList<WaitModel>();
//实例化一个文档构建器工厂
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//通过文档构建器工厂获取一个文档构建器
DocumentBuilder builder = factory.newDocumentBuilder();
//通过文档通过文档构建器构建一个文档实例
Document document = builder.parse(inStream);
Element root = document.getDocumentElement();
NodeList nodes = root.getElementsByTagName("Table");
for(int i = 0 ;i < nodes.getLength();i++)
{
Element personElement = (Element)nodes.item(i);
WaitModel waitModel =new WaitModel();
// waitModel.setId(Integer.valueOf(personElement.getAttribute("id")));
NodeList childNodes = personElement.getChildNodes();
for(int j = 0;j<childNodes.getLength();j++)
{
Node childNode = (Node)childNodes.item(j);
if (childNode.getNodeType()==Node.ELEMENT_NODE)
{
Element childElement = (Element)childNode;
if ("PLAN_DATE".equals(childElement.getNodeName()))
{
waitModel.setPLAN_DATE(childElement.getFirstChild().getNodeValue());
}
else if ("CORPORATION_NAME_ABB".equals(childElement.getNodeName())) {
waitModel.setCORPORATION_NAME_ABB(childElement.getFirstChild().getNodeValue());
}
else if ("ASSIGN_STATUS".equals(childElement.getNodeName())) {
waitModel.setASSIGN_STATUS(childElement.getFirstChild().getNodeValue());
}
else if ("WORK_ASSIGN_NO".equals(childElement.getNodeName())) {
waitModel.setWORK_ASSIGN_NO(childElement.getFirstChild().getNodeValue());
}
}
}
waitModels.add(waitModel);
}
return waitModels;
}

转:http://chen249045216.iteye.com/blog/1121586

Android 调用webservice并解析的更多相关文章

  1. Android调用WebService(转)

    Android调用WebService WebService是一种基于SOAP协议的远程调用标准,通过 webservice可以将不同操作系统平台.不同语言.不同技术整合到一块.在Android SD ...

  2. 纠正网上乱传的android调用Webservice方法。

    1.写作背景: 笔者想实现android调用webservice,可是网上全是不管对与错乱转载的文章,结果不但不能解决问题,只会让人心烦,所以笔者决定将自己整理好的能用的android调用webser ...

  3. 网摘Android调用WebService

    这边特别注意调用的.net WCF 接口的绑定方式.以前一直用的wxHttpbinding,一直连不上.改成BasicHTTPbinding就能连上了 上篇文章已经对Web Service及其相关知识 ...

  4. Android 调用 WebService

    1.WebService简介 PS:如果看完上面简介还不是很清楚的话,那么就算了,之前公司就用C#搭的一个WebService! 本节我们并不讨论如何去搭建一个WebService,我们仅仅知道如何去 ...

  5. ksoap2 android 调用WebService

    webService,soap,wsdl的基本概念? 详情请看维基百科 基于soap 1.1, soap 1.2 的请求和响应数据源 查找了很久都是基于json格式传输数据,但是最终还是找到了基于xm ...

  6. Android调用WebService

    这两天给老师做地铁app的demo,与后台的交互要用WebService,还挺麻烦的.所以想写点,希望有用. Web Services(Web服务)是一个用于支持网络间不同机器互操作的软件系统,它是一 ...

  7. 第十五章:Android 调用WebService(.net平台)

    什么是webservice? Web service是一个平台独立的,低耦合的,自包含的.基于可编程的web的应用程序,可使用开放的XML(标准通用标记语言下的一个子集)标准来描述.发布.发现.协调和 ...

  8. Android 调用webService(.net平台)

    什么是webservice? Web service是一个平台独立的,低耦合的,自包含的.基于可编程的web的应用程序,可使用开放的XML(标准通用标记语言下的一个子集)标准来描述.发布.发现.协调和 ...

  9. 【Android进阶】Android调用WebService的实现

    最近想自己搞搞服务器,就从最简单的webservice开始吧 先上效果图 项目结构 开始贴代码,注释都有,有问题的请留言 MainActivity.java package com.example.w ...

随机推荐

  1. Java 8新的时间日期库的20个使用示例

    原文链接 作者:Javin Paul 译者:之诸暇 除了lambda表达式,stream以及几个小的改进之外,Java 8还引入了一套全新的时间日期API,在本篇教程中我们将通过几个简单的任务示例来学 ...

  2. 黑镜第一至二季/全集Black Mirror迅雷下载

    本季第一.二季 Black Mirror (2011-2013)看点:<黑镜>(Black Mirror)是一部由查理·布洛克主创.英国电视4台(Channel 4)于2011年12月播出 ...

  3. Android之仿iphone抖动效果

    转自:http://blog.csdn.net/long33long/article/details/7693671 布局文件: <?xml version="1.0" en ...

  4. M2Crypto安装方法以及配置LDFLAGS、CFLAGS

    python3.7+mac环境: $ brew install openssl && brew install swig $ brew --prefix openssl /usr/lo ...

  5. Guava Finalizer

    /* * Copyright (C) 2008 The Guava Authors Licensed under the Apache License, Version 2.0 (the " ...

  6. C# Encoding UTF-16 ,C#中的UTF16

    http://www.cnblogs.com/criedshy/archive/2012/08/07/2625358.html 前言 众所周知计算机只能识别二进制数字,如1010,1001.我们屏幕所 ...

  7. Verilog 加法器和减法器(5)

    前面二进制加法运算,我们并没有提操作数是有符号数,还是无符号数.其实前面的二进制加法对于有符号数和无符号数都成立.比如前面的8位二进制加法运算,第一张图我们选radix是unsigned,表示无符号加 ...

  8. git: error while loading shared libraries: libiconv.so.2

    git安装之后出现:git: error while loading shared libraries: libiconv.so.2: cannot open shared object file: ...

  9. [leetcode]Max Points on a Line @ Python

    原题地址:https://oj.leetcode.com/problems/max-points-on-a-line/ 题意:Given n points on a 2D plane, find th ...

  10. JQuery效率问题

    1,前言 我们开发了一个专题系统,生成了JSON的数据格式,采用JQuery动态插入HTML中,在前期的使用中,没有太大的问题,效率还可以接受,但是最近可能由于网络加之页面设计问题,我们的JS效率比较 ...