美文网首页
Retrofit2:xml作为参数

Retrofit2:xml作为参数

作者: 芋头_ | 来源:发表于2017-04-14 15:50 被阅读0次

    1.请求接口

    public interface IWechatService {
      @POST
       Call<ResponseBody> prepay(@Url String uri,@Body RequestBody route);
    }
    

    2.请求

    
    Retrofit  retrofit = new Retrofit.Builder().baseUrl(weChatPrepayUrl)
                    .build();
    IWechatService wechatService = retrofit.create(IWechatService.class);
    
    RequestBody route = RequestBody.create(MediaType.parse("application/xml;charset=UTF-8"),xml);
    
    Call<ResponseBody> call = wechatService.prepay(weChatPrepayUri,route);
        try {
            String value  = call.execute().body().string();
            Map<String,String> map = XmlUtil.parseXml(value);
            return  map.get("prepay_id");
        } catch (IOException | DocumentException e) {
            e.printStackTrace();
        }
    

    相关文章

      网友评论

          本文标题:Retrofit2:xml作为参数

          本文链接:https://www.haomeiwen.com/subject/fxowattx.html