Flutter肥皂:如何在Flutter中使用SOAP?

zour9fqk  于 2023-05-23  发布在  Flutter
关注(0)|答案(2)|浏览(192)

如何在Flutter中使用SOAP API调用?我试过休息电话工作正常。我需要在flutter中构建SOAP调用。请分享如何在Flutter中调用SOAP

qybjjes1

qybjjes11#

参考此链接成功调用SOAP https://dartpad.dartlang.org/2561dd3579e45d1eb730

void functionCall() async {
    var envelope = '''
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <GetAllCity xmlns="http://tempuri.org/" />
  </soap:Body>
</soap:Envelope>
''';

    http.Response response = await http.post(
        'http://www.i2isoftwares.com/SSKSService/sskss.asmx',
        headers: {
          "Content-Type": "text/xml; charset=utf-8",
          "SOAPAction": "http://tempuri.org/GetAllCity",
          "Host": "www.i2isoftwares.com"
          //"Accept": "text/xml"
        },
        body: envelope);

    var rawXmlResponse = response.body;

// Use the xml package's 'parse' method to parse the response.
    xml.XmlDocument parsedXml = xml.parse(rawXmlResponse);

    print("DATAResult=" + response.body);
  }
14ifxucb

14ifxucb2#

这是一个很古老的问题,但我的答案也许会帮助到一些人。
最近,我还不得不连接到SOAPWeb服务,但我不想手动创建SOAP请求。经过长时间的研究,我发现了一个付费工具easyWSDL,它可以从Web服务WSDL生成所有类。然后,您可以将所有这些类添加到项目中,并使用它们连接到API。在这种情况下,您不需要了解有关SOAP规范的任何细节和任何其他内部内容。
这就像工具一样:wsdl2java(在Java中)或svcutil(在.NET中)。快速和简单的解决方案。

相关问题