Home > Back-end >  Delphi using MSXML2. XMLHTTP invoke the webservice helloworld with parameters, how to input paramete
Delphi using MSXML2. XMLHTTP invoke the webservice helloworld with parameters, how to input paramete

Time:09-27

C # webservice

The HelloWorld

The test
If you want to use HTTP POST protocol testing operation, please click the "call" button,
The parameter value
Test:


SOAP 1.1
The following is a SOAP request and response 1.2 example, shows a placeholder to replace with the actual value,

POST/HandlePatient asmx HTTP/1.1
Host: 192.168.33.238
The content-type: text/XML. Charset=utf-8
The Content - Length: Length
SOAPAction: "http://tempuri.org/HelloWorld"

<? The XML version="1.0" encoding="utf-8"?>

String



HTTP/1.1 200 OK
The content-type: text/XML. Charset=utf-8
The Content - Length: Length

<? The XML version="1.0" encoding="utf-8"?>

String



SOAP 1.2
The following is a SOAP request and response 1.2 example, shows a placeholder to replace with the actual value,

POST/HandlePatient asmx HTTP/1.1
Host: 192.168.33.238
The content-type: application/soap + XML; Charset=utf-8
The Content - Length: Length

<? The XML version="1.0" encoding="utf-8"?>

String



HTTP/1.1 200 OK
The content-type: application/soap + XML; Charset=utf-8
The Content - Length: Length

<? The XML version="1.0" encoding="utf-8"?>

String



HTTP GET
Example, the following is a HTTP GET request and response shows a placeholder to be replaced with actual values,

GET/HandlePatient. Asmx/HelloWorld? Test=string HTTP/1.1
Host: 192.168.33.238

HTTP/1.1 200 OK
The content-type: text/XML. Charset=utf-8
The Content - Length: Length

<? The XML version="1.0" encoding="utf-8"?>

HTTP POST
The following is a sample HTTP POST request and response, shows a placeholder to replace with the actual value,

POST/HandlePatient. Asmx/HelloWorld HTTP/1.1
Host: 192.168.33.238
The content-type: application/x - WWW - form - urlencoded
The Content - Length: Length

Test=string
HTTP/1.1 200 OK
The content-type: text/XML. Charset=utf-8
The Content - Length: Length

<? The XML version="1.0" encoding="utf-8"?>




Delphi code

Procedure TForm1. Button1Click (Sender: TObject);
Var
Url, inxml, outxml, ErrorMsg, Trade_Id: string;
XmlHttp: Olevariant;
Xmldoc: Olevariant;
I, rtrn_code: integer;
Doc: IXMLDocument;
The node, the rootnode: IXMLNODE;
Params: the string;
XML: TStringStream;
The begin
//Trade_Id='getHospitalInfo';
//url:='http://127.0.0.1:8082/doReqToHis? Service=getHospitalInfo ';
//inxml:='& lt; ? The XML version="1.0" encoding="utf-8"?> '
//+ '& lt; Request the op="HelloWorld" & gt; '//interface number
//+ '& lt; Aa> 00011 & lt;/aa> ';
Url:=Edit1. Text;
Inxml:=Memo1. Text;
Try
XmlHttp:=CreateOleObject (' MSXML2. XmlHttp);//IE version cannot be lower than 6.0
Xmldoc:=CreateOleObject (' MSXML. DOMDocument ');//will determine the XML versions of components to each other in
Except,
Showmessage (' create XML component failure! ');
The Exit;
The end;
Try
//call the XMLHTTP component method
//xmlHttp. SetRequestHeader (' the content-type ', 'application/x - WWW - form - urlencoded ");
Params:='test=' + inxml;
XmlHttp. Open (' POST 'url, false);
XMLHTTP. SetRequestHeader (' the content-type ', 'application/x - WWW - form - urlencoded ");
//XMLHTTP. SetRequestHeader (' the content-type ', 'text/XML. charset=utf-8');
XMLHTTP. SetRequestHeader (' Content - Length, 1000);
XMLHTTP. SetRequestHeader (' cache-control ', 'no - Cache).
XmlHttp. SetRequestHeader (' Host ', '192.168.33.238:20012');
Xmldoc. Loadxml (inxml);
XmlHttp. Send (params);
//delay processing
I:=0;
While xmlHttp. Readystate & lt;> 4 do
The begin
I:=I + 1;
If I & gt; Then 10000000
The begin
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related