小编Jav*_*vad的帖子

Retrofit:如何发出 XML 请求并获取 JSON 响应

我怎样才能发出一个简单的text/xml POST请求并使用retrofit 2取回JSON!!!???
注 1:我已经知道如何发出 JSON GET/POST 请求并获取 JSON 作为响应。
注 2:我有一个端点,其中请求采用 XML SOAP 格式,响应采用 JSON 格式。为了澄清起见,我将在此处发布示例请求响应:

XML 示例请求:

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
  <soap12:Body>
    <Login xmlns="http://tempuri.org/">
      <username>0370079361</username>
      <password>4321</password>
    </Login>
  </soap12:Body>
</soap12:Envelope>
Run Code Online (Sandbox Code Playgroud)


JSON 示例响应:

{
    "UserID": 2081,
    "FailureText": null,
    "UserValidPasswordCode": 2081,
    "UserPatientIsActiveWithNationalIDCode": true
}
Run Code Online (Sandbox Code Playgroud)

xml android json xmlhttprequest retrofit2

5
推荐指数
1
解决办法
5388
查看次数

标签 统计

android ×1

json ×1

retrofit2 ×1

xml ×1

xmlhttprequest ×1