Consuming SOAP in Flutter, storing Cookie

Asked

Viewed 84 times

0

Good morning everyone, I’m having a hard time, I need to consume a WS in SOAP, when I use Postman works, but when I try to work with the data in Flutter, it’s not working, I think it’s something in the body of the message, has anyone been there ?

No Flutter, status = 0 means I didn’t authenticate, the status = 1 returns a key, which I must store for later requests

Future<void> _getAuth() async {
    String headerAuth = "<serviceRequest serviceName='MobileLoginSP.login>'" +
        "<requestBody>" +
        "<NOMUSU>juliano.conceicao</NOMUSU>" +
        " <INTERNO>1d9fc5e6</INTERNO>" +
        "</requestBody>" +
        "</serviceRequest>";

    final response = await http.post(
      "http://172.30.0.6:8280/mge/service.sbr?serviceName=MobileLoginSP.login",
      headers: {
        "Content-Type": "text/xml",
      },
      body: headerAuth,
    );

    print("body: ${response.body}");
  }
//resposta do Body

I/flutter (10728): cocokie: <?xml version="1.0" encoding="utf-8"?>
I/flutter (10728): <serviceResponse serviceName="MobileLoginSP.login" status="0" pendingPrinting="false" transactionId="3EAFA46D5B5470393F3858D97ADD025B"><statusMessage><![CDATA[RWxlbWVudCB0eXBlICJzZXJ2aWNlUmVxdWVzdCIgbXVzdCBiZSBmb2xsb3dlZCBieSBlaXRoZXIg
I/flutter (10728): YXR0cmlidXRlIHNwZWNpZmljYXRpb25zLCAiPiIgb3IgIi8+Ii4=
I/flutter (10728): ]]></statusMessage></serviceResponse>

Using the Postman

POST: http://172.30.0.6:8280/mge/service.sbr?serviceName=MobileLoginSP.login 
Body:
<serviceRequest serviceName="MobileLoginSP.login">
  <requestBody>
    <NOMUSU>juliano.conceicao</NOMUSU>
    <INTERNO>1d9fc5e6</INTERNO>
  </requestBody>
</serviceRequest>

Body de Retorno note status = 1 de sucesso

<?xml version="1.0" encoding="ISO-8859-1"?>
<serviceResponse serviceName="MobileLoginSP.login" status="1" pendingPrinting="false" transactionId="2BC5A4E9EC98C6ECB75AC998E2E74AA5">
    <responseBody>
        <jsessionid>C3LeL-J1x-hQKSn7-TUxoOjow7BXyL8Cfn4kM8sP</jsessionid>
        <idusu>MTM5
</idusu>
        <callID>7278E887855ACEE0AACA2451A5C681F9</callID>
    </responseBody>
</serviceResponse>

1 answer

3

Hello, I think you’ve mistaken the position of ', placed after login> the ', and got the wrong syntax and try to invert the quotes by apostrophes. The quotes you leave to "Mobileloginsp.login". See below.

 String headerAuth = '<serviceRequest serviceName="MobileLoginSP.login">' +
            '<requestBody>' +
            '<NOMUSU>juliano.conceicao</NOMUSU>' +
            ' <INTERNO>1d9fc5e6</INTERNO>' +
            '</requestBody>' +
            '</serviceRequest>';

Browser other questions tagged

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