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();
}
网友评论