急!!!!!如何实现向https(http +ssL) 传xml文件(10分)

  • 主题发起人 主题发起人 cainiao999
  • 开始时间 开始时间
C

cainiao999

Unregistered / Unconfirmed
GUEST, unregistred user!
如何实现向向https, post xml文件,

该段函数报错,,,任意采用其它方法都成只要实现向https(http +ssL) 传xml文件

function TForm1.FetchWithWinHttpRequest(var xml: string): Integer;

const url = 'https://b2bportalprevie…………………………';

const proxyServer = '10.128.2.13:80';

const proxyBypass = '127.0.0.1';

// HttpRequest SetCredentials flags.

const HTTPREQUEST_PROXYSETTING_DEFAULT = 0;

const HTTPREQUEST_PROXYSETTING_PRECONFIG = 0;

const HTTPREQUEST_PROXYSETTING_DIRECT = 1;

const HTTPREQUEST_PROXYSETTING_PROXY = 2;



var

WinHttpRequest: OLEVariant;

errorCode: Integer;

//sstatus: string;

begin

// Initially set the return value of the function to 0

Result := 0;

//XML := '<QDS_Data></QDS_Data>';

try

// Create the WinHttpRequest COM object

WinHttpRequest := CreateOLEObject('WinHttp.WinHttpRequest.5.1'); 运行到这行报错,该参数—--无效字符串

// Set proxy server and bypass list

errorCode := WinHttpRequest.setProxy(HTTPREQUEST_PROXYSETTING_PROXY, proxyServer, proxyBypass);

// Set timeouts

WinHttpRequest.setTimeouts(10000, 10000, 10000, 10000);

//WinHttpRequest.Option[WinHttpRequestOption_SslErrorIgnoreFlags := 13056];

WinHttpRequest.Open('POST', url, False);

WinHttpRequest.SetRequestHeader('Content-Type', 'text/xml');

WinHttpRequest.SetRequestHeader('Content-Length', Length(xml));

WinHttpRequest.SetCredentials(user, passw, 0);

errorCode := WinHttpRequest.send(xml);

if errorCode = S_OK then begin

Result := WinHttpRequest.status;

end

except

on E: Exception do begin

Result := -1

end;

end;

end;
 
后退
顶部