加载数据失败500我不明白问题到底出在哪里,有人能帮我吗?
我认为有一些问题在我的代码,但我不知道在哪里
'
class UserProvider{
TextEditingController motDePasseController = TextEditingController();
TextEditingController identifiantController = TextEditingController();
final _body = '''
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="link"
xmlns:ser="http:/link.fr/">
<soapenv:Header/>
<soapenv:Body>
<ser:authentifierUtilisateur>
</ser:authentifierUtilisateur>
</soapenv:Body>
</soapenv:Envelope>'link';
UserProvider(){}
Future<List<UsersModel>> loginUser( ) async{
try{
var response = await http.post( Uri.parse(''),
headers: { 'content-type': 'text/xml; charset=utf-8',
'SOAPAction': '',
HttpHeaders.authorizationHeader: '4e1bae794a5a905db6620ab0be1c593c',
},
body: utf8.encode(_body),
);
if(response.statusCode == 200){
identifiantController.clear();
motDePasseController.clear();
// Get.off(const HomePage());
final responseBody = response.body;
final parseXml = xml.XmlDocument.parse(responseBody).innerText;
final decodeJson = jsonDecode(parseXml) as List;
List<UsersModel> data =
decodeJson.map((e) => UsersModel.fromJson(e)).toList();
return data;
} else{ print(response.statusCode.toString());
throw Exception('Failed load data ${response.statusCode}');
}
}catch(error){
print (error);
throw error;}
}
}`
1条答案
按热度按时间yc0p9oo01#
您应该在
_body
上使用以下代码: