How to mount an XML string with SOAP?

Asked

Viewed 272 times

-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:

Documentation Here

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();
    }
  • 1

    Have you tried a model similar to the one in here? https://stackoverflow.com/questions/53505624/soap-request-in-flutter-dart .

1 answer

0


I decided as follows:

I installed a plugin in Google Chrome that helps interpret the methods embedded within the Webservice url:

Wizdler

Url of the webservice:

https://ssw.inf.br/ws/sswColeta/index.php?wsdl

Extracted Collect() Method:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <coletar xmlns="urn:sswinfbr.sswColeta">
            <dominio>[string]</dominio>
            <login>[string]</login>
            <senha>[string]</senha>
            <cnpjRemetente>[string]</cnpjRemetente>
            <cnpjDestinatario>[string]</cnpjDestinatario>
            <numeroNF>[string]</numeroNF>
            <tipoPagamento>[string]</tipoPagamento>
            <enderecoEntrega>[string]</enderecoEntrega>
            <cepEntrega>[integer]</cepEntrega>
            <solicitante>[string]</solicitante>
            <limiteColeta>[dateTime]</limiteColeta>
            <quantidade>[integer]</quantidade>
            <peso>[decimal]</peso>
            <observacao>[string]</observacao>
            <instrucao>[string]</instrucao>
            <cubagem>[decimal]</cubagem>
            <valorMerc>[decimal]</valorMerc>
            <especie>[string]</especie>
        </coletar>
    </Body>
</Envelope>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.