其他分享
首页 > 其他分享> > idhttpserver 接受xml的数据。

idhttpserver 接受xml的数据。

作者:互联网

req := CoXMLHTTP.Create;
  try
    req.open('Post', szUrl, False, EmptyParam, EmptyParam);
    //设置post必要参数
    req.setRequestHeader('UserAgent','Mozilla/5.0');
    req.setRequestHeader('AcceptCharSet', 'utf-8');
    req.setRequestHeader('Content-Type', 'application/json');
    req.setRequestHeader('Date',IntToStr(tmUnix));
    req.setRequestHeader('APPID',AppID);
    req.setRequestHeader('Content-MD5',OutText);

    /Params := '';//UTF8Encode(json);  不需要转换utf8
    //提交数据
    vParams := body;//UTF8Encode(json);  不需要转换utf8
    //发送请求
    req.send(vParams);
    Sleep(10);
    v := req.responseText;
    //szValue := WideStrToString(v); //宽字符转为 ,可有可无
    szValue := v;
    ResultXml := PAnsiChar(AnsiString(szValue));/Stream;
    req.abort;
    Result := true;
  except
    Result := false;
  end;

req: IXMLHTTPRequest;

 

use msxml

标签:xml,idhttpserver,req,setRequestHeader,Content,json,szValue,vParams,接受
来源: https://www.cnblogs.com/Thenext/p/16306152.html