Retrofit2:xml作为参数

1.请求接口

public interface IWechatService {
  @POST
   Call 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 call = wechatService.prepay(weChatPrepayUri,route);
    try {
        String value  = call.execute().body().string();
        Map map = XmlUtil.parseXml(value);
        return  map.get("prepay_id");
    } catch (IOException | DocumentException e) {
        e.printStackTrace();
    }

你可能感兴趣的:(Retrofit2:xml作为参数)