⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.pas

📁 这是一套全面的网络组件
💻 PAS
字号:
unit main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, clHttpRequest, clSoap, clTcpClient, clHttp;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    cbCompany: TComboBox;
    btnStart: TButton;
    Label4: TLabel;
    edtQuote: TEdit;
    clSoapMessage: TclSoapMessage;
    Label5: TLabel;
    clHttp1: TclHttp;
    procedure btnStartClick(Sender: TObject);
  private
    function ExtractQuoteValue(const AResponse: string): string;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function TForm1.ExtractQuoteValue(const AResponse: string): string;
var
  ind, indEnd: Integer;
begin
  Result := LowerCase(AResponse);
  ind := Pos('<result', Result);
  if (ind > 0) then
  begin
    Result := Copy(Result, ind + 1, 1000);
    ind := Pos('>', Result);
    indEnd := Pos('<', Result);
    Result := Copy(Result, ind + 1, indEnd - ind - 1);
  end;
end;

procedure TForm1.btnStartClick(Sender: TObject);
var
  msg, response: TStrings;
begin
  msg := TStringList.Create();
  response := TStringList.Create();
  try
    msg.Add('<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema">');
    msg.Add('<SOAP-ENV:Body>');
    msg.Add('<ns1:getQuote xmlns:ns1="urn:xmethods-delayed-quotes" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">');

    msg.Add('<symbol xsi:type="xsd:string">' + cbCompany.Text + '</symbol>');

    msg.Add('</ns1:getQuote>');
    msg.Add('</SOAP-ENV:Body>');
    msg.Add('</SOAP-ENV:Envelope>');

    clSoapMessage.BuildSoapRequest(msg, 'urn:xmethods-delayed-quotes#getQuote');

    clHttp1.Post('http://services.xmethods.net/soap', response);

    edtQuote.Text := ExtractQuoteValue(response.Text);
  finally
    response.Free();
    msg.Free();
  end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -