WebService 网络请求库 WsNet

码农软件 · 软件分类 · 手机开发包 · 2019-05-04 15:43:07

软件介绍

WsNet 是一个 android WebService 的网络请求库。

添加对应的maven库地址

maven {  
   url "https://raw.githubusercontent.com/zdmisif/WsNet/master"  
}

添加对应的库

dependencies{  
        compile 'com.sandu.develop:wsnet:0.0.1'  
}

三方库使用的简单说明

1.创建Wsnet对象,初始化Webservice的服务名和接入点(用网上查询IP所属地的Webservice作为例子)

Wsnet wsnet = new Wsnet();
wsnet.init("http://WebXml.com.cn/", "http://www.webxml.com.cn/WebServices/IpAddressSearchWebService.asmx");

2.生成一个定义方法的接口类

public interface WsApi {

    @WsMethodName("getCountryCityByIp")
    WsCall getCountryCityByIp(@WsParam("theIpAddress") String theIpAddress);

}

WsMethodName 对应声明对应的方法

WsParam 对应方法的参数

WsFileParam 上传图片的参数,传的是图片数据类型为byte[]

类似Retrofit的用法

3.创建接口对应的一个实体类,调用对应的方法即可

WsApi wsApi = wsnet.create(WsApi.class);
wsApi.getCountryCityByIp("119.132.20.130").execute(new WsCallBack() {
            @Override
            public void onSuccess(String result) {
                //返回的结果数据
            }

            @Override
            public void onFaile(String error) {
                //调用的错误,返回错误信息
            }
        });

PS:目前对返回的数据,都是返回一个字符串,具体返回的数据格式,需要在得到对应的结果数据再进行转换。

本文地址:https://codercto.com/soft/d/5011.html

Computing Patterns in Strings

Computing Patterns in Strings

Bill Smyth / Addison Wesley / 2003 / $ 75.00

The computation of patterns in strings is a fundamental requirement in many areas of science and information processing. The operation of a text editor, the lexical analysis of a computer program, the......一起来看看 《Computing Patterns in Strings》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

SHA 加密
SHA 加密

SHA 加密工具