-2
I don’t know how to ride STRING
of XML
correct way to send the parameters with xml. According to the documentation the method is called coletar()
but I am not able to pass these parameters correctly, always gives Erro 500
:
void main() async {
String soap = '''
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding">
<soap:Body>
<coletar>
<part>
<dominio>luz</dominio>
</part>
<part>
<login>"user"</login>
</part>
<part>
<senha>"123456"</senha>
</part>
<part>
<cnpjRemetente>"000.000.000-00"</cnpjRemetente>
</part>
<part>
<cnpjDestinatario>"000.000.000-00"</cnpjDestinatario>
</part>
<part>
<numeroNF>"123456"</numeroNF>
</part>
<part>
<tipoPagamento>"D"</tipoPagamento>
</part>
<part>
<enderecoEntrega>"Av Norte 1345"</enderecoEntrega>
</part>
<part>
<cepEntrega>"578888-999"</cepEntrega>
</part>
<part>
<solicitante>"Ricardo"</solicitante>
</part>
<part>
<limiteColeta>"20-05-2020"</limiteColeta>
</part>
<part>
<quantidade>"10"</quantidade>
</part>
<part>
<peso>"10"</peso>
</part>
<part>
<observacao>"nenhuma"</observacao>
</part>
<part>
<cubagem>"30"</cubagem>
</part>
<part>
<valorMerc>"50"</valorMerc>
</part>
<part>
<especie>"não especificado"</especie>
</part>
</coletar>
</soap:Body>
</soap:Envelope> ''';
postOTP("https://ssw.inf.br/ws/sswColeta/index.php", soap);
}
Future<String> postOTP(String _uri, String _message) async {
HttpClient client = new HttpClient();
HttpClientRequest request = await client.postUrl(Uri.parse(_uri));
request.write(_message);
HttpClientResponse response = await request.close();
StringBuffer _buffer = new StringBuffer();
await for (String a in await response.transform(utf8.decoder)) {
_buffer.write(a);
}
print("_buffer.toString: ${_buffer.toString()}");
return _buffer.toString();
}
Have you tried a model similar to the one in here? https://stackoverflow.com/questions/53505624/soap-request-in-flutter-dart .
– Leonardo Paim