zoukankan      html  css  js  c++  java
  • android访问webservices

    /**
    * 手机号段归属地查询(模拟器、HTC 可以)

    * @param phoneSec 手机号段
    */
    public  void getRemoteInfo() {

    /*String phoneSec ="1860028";
    // 命名空间
    String nameSpace = "http://WebXml.com.cn/";
    // 调用的方法名称
    String methodName = "getMobileCodeInfo";
    // EndPoint
    String endPoint = "http://webservice.webxml.com.cn/WebServices/MobileCodeWS.asmx";
    // SOAP Action
    String soapAction = "http://WebXml.com.cn/getMobileCodeInfo";*/




    String nameSpace = "http://phone.centen.com";
    String methodName = "LoginCertification";
    String endPoint = "http://192.168.0.94:83/phoneService/services/PhoneWebService";
      
    String soapAction = "http://phone.centen.com/LoginCertification";




    // 指定WebService的命名空间和调用的方法名
    SoapObject rpc = new SoapObject(nameSpace, methodName);


    // 设置需调用WebService接口需要传入的两个参数mobileCode、userId
    rpc.addProperty("userId", "系统管理员");
    rpc.addProperty("psw", "123");


    // 生成调用WebService方法的SOAP请求信息,并指定SOAP的版本
    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10);


    envelope.bodyOut = rpc;
    // 设置是否调用的是dotNet开发的WebService
    envelope.dotNet = false;
    // 等价于envelope.bodyOut = rpc;
    envelope.setOutputSoapObject(rpc);


    HttpTransportSE transport = new HttpTransportSE(endPoint);
    try {
    // 调用WebService
    transport.call(soapAction, envelope);
    } catch (Exception e) {
    e.printStackTrace();
    }
    // 获取返回的数据
    SoapObject object = (SoapObject) envelope.bodyIn;
    // 获取返回的结果
    String result = object.getProperty(0).toString();

    System.err.println(">>>>>>>>>>>>>"+result);
    }

  • 相关阅读:
    Android Studio学习笔记(1)
    2019全国大学生电子设计大赛总结
    包与常用模块
    模块
    迭代器、生成器与递归调用
    叠加多个装饰器与有参数的装饰器。
    装饰器
    控制指针的移动、函数
    字符编码
    python 数据类型之列表、元组、字典、集合
  • 原文地址:https://www.cnblogs.com/pangblog/p/3395372.html
Copyright © 2011-2022 走看看