【发布时间】:2019-11-13 12:39:09
【问题描述】:
返回类型“响应”有问题。我真的不知道如何处理这种类型。 我必须转换它。我只想在屏幕上显示响应。
谁能解释一下这个问题?
var username = 'dslf-config';
var password = '53259721';
static String port = "37443";
String url = 'https://192.168.2.1:' + port;
//unused.... String parameter = 'Device.DeviceInfo.ModelName';
var body = """
<?xml version="1.0" encoding= "UTF-8" ?>
<soap-env:Envelope soap-enc="http://schemas.xmlsaop.org/soap/encoding/" xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:cwmp="urn:telekom-de.totr64-2-n">
<soap-env:Body>
<cwmp:GetParameterValues xmlns:cwmp="urn:dslforum-org:cwmp-1-0">
<cwmp:ParameterNames soap-env:arrayType="xsd:string[10]">
<xsd:string>Device.DeviceInfo.ModelName</xsd:string>
</cwmp:ParameterNames>
</cwmp:GetParameterValues>
</soap-env:Body>
</soap-env:Envelope>""";
Future<http.Response> getData2() {
bool trustSelfSigned = true;
Map<String, String> headers = {
"Accept": "*/*",
"Content-Type": "text/xml",
"SOAPAction":
"urn:telekom-de:device:TO_InternetGatewayDevice:2#GetParameterValues"
};
HttpClient httpClient = new HttpClient()
..badCertificateCallback =
((X509Certificate cert, String host, int port) => trustSelfSigned);
httpClient.addCredentials(Uri.parse(url), "theRealm",
new HttpClientDigestCredentials(username, password));
IOClient ioClient = new IOClient(httpClient);
return ioClient.post(Uri.parse(url), headers: headers, body: body);
}
getData3() async {
final response = await getData2();
print(response.body);
print(response.statusCode);
print(response.headers);
}
【问题讨论】:
标签: http flutter xmlhttprequest response httpresponse