加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

Retrofit实现请求WebService 看这篇就够了。

发布时间:2020-12-16 21:47:22 所属栏目:安全 来源:网络整理
导读:先看这篇文章: http://www.vogella.com/tutorials/Retrofit/article.html 再看这篇文章: http://www.jianshu.com/p/6e4e53d8efe8?winzoom=1 需要注意的几个地方就是 1 在你的接口处 需要设置soapAction 比如 interface Api{ @Headers ({ "Content-Type: te

先看这篇文章:
http://www.vogella.com/tutorials/Retrofit/article.html
再看这篇文章:
http://www.jianshu.com/p/6e4e53d8efe8?winzoom=1

需要注意的几个地方就是

1 在你的接口处 需要设置soapAction
比如

interface Api{
@Headers({
            "Content-Type: text/xml","SOAPAction: http://tempuri.org/GetPlayFileInfo" //一般这里是需要调用的方法名
    })
    @POST("BsSchoolWebService.asmx")
    Call<GetPlayFileInfoRootBean> GetPlayFileInfo(@Body GetPlayFileInfoBean getPlayFileInfoBean);
}

2 在你需要传递参数的对象上需要设置 NamespaceList 比如

@Root(name = "soap:Envelope",strict = false)
@NamespaceList({
        @Namespace(reference = "http://www.w3.org/2001/XMLSchema-instance",prefix = "xsi"),@Namespace(reference = "http://www.w3.org/2001/XMLSchema",prefix = "xsd"),@Namespace(reference = "http://schemas.xmlsoap.org/soap/envelope/",prefix = "soap")
})
public class GetPlayFileInfoBean {
    @Element(name = "GetPlayFileInfo")
    @Path("soap:Body")
    private GetPlayFileInfoBeanChild GetPlayFileInfochildl;

    public GetPlayFileInfoBeanChild getGetPlayFileInfochildl() {
        return GetPlayFileInfochildl;
    }

    public void setGetPlayFileInfochildl(GetPlayFileInfoBeanChild getPlayFileInfochildl) {
        GetPlayFileInfochildl = getPlayFileInfochildl;
    }
}

其他操作参考上面2个链接就可以了。哈哈。 有问题留言。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读