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);
    }

  • 相关阅读:
    javaweb:Filter过滤器
    javaScript:高级
    javascript:基础
    Boostrao:轮播图
    Bootstrap案列:首页界面
    Bootstrap学习笔记
    javaweb:respone
    javaweb:jsp
    五、结构型模式--->07.享元模式
    五、结构型模式--->06.组合模式
  • 原文地址:https://www.cnblogs.com/pangblog/p/3395372.html
Copyright © 2011-2022 走看看