Discuz!NT|BBS|论坛

注册

 

发新话题 回复该主题

webservice原始调用 [复制链接]

1#
void loginajax(String sfunction, String susername, String suserpass) async{

    String requestBody = "";

    String ssss = "";

    ssss = generateMd5("666666").toUpperCase();

    //print(ssss);

    requestBody += "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
    requestBody += "<soap:Envelope xmlnssi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlnssd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">";
    requestBody += "<soap:Body>";
    requestBody += "<" + sfunction + " xmlns=\"" + Constant.KHAPPURL + "/\">";
    requestBody += "<scorp_id>" + "000001" + "</scorp_id>";
    requestBody += "<scorp_password>" + ssss+ "</scorp_password>";
    requestBody += "</" + sfunction + ">";
    requestBody += "</soap:Body>";
    requestBody += "</soap:Envelope>";

    http.Response response = await http.post(
        Constant.KHAPPURL + "/webappsrv.asmx",
        headers: {
          "SOAPAction": Constant.KHAPPURL + sfunction,
          "Content-Type": "text/xml;charset=UTF-8",
          "Authorization": "Basic bWVzdHJlOnRvdHZz",
          "cache-control": "no-cache"
        },
        body: utf8.encode(requestBody),
        encoding: Encoding.getByName("UTF-8")
    ).then((onValue)
    {
      print("Response status: ${onValue.statusCode}");
      //print("Response body: ${onValue.body}");

      //Response status: 200

      //{"respcode":"0","errcode":"1001","respmsg":"APP参数校验非法!"}

      String sresp = onValue.body;

      sresp = sresp.replaceAll("<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlnssi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlnssd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><" + sfunction + "Response xmlns=\"" + Constant.KHAPPURL + "\"><" + sfunction + "Result>", "");

      sresp = sresp.replaceAll("</" +  sfunction + "Result></" + sfunction + "Response></soap:Body></soap:Envelope>", "");

      ToastUtil.show(sresp);

    });
  }
分享 转发
TOP
发新话题 回复该主题