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
先看这篇文章: 需要注意的几个地方就是 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个链接就可以了。哈哈。 有问题留言。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |