delphi利用MSXML2.XMLHTTP调用webservice带参数helloworld,参数要怎么录入
c#webservice
HelloWorld
测试
若要使用 HTTP POST 协议对操作进行测试,请单击“调用”按钮。
参数 值
test:
SOAP 1.1
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /HandlePatient.asmx HTTP/1.1
Host: 192.168.33.238
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/HelloWorld"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorld xmlns="http://tempuri.org/">
<test>string</test>
</HelloWorld>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorldResponse xmlns="http://tempuri.org/">
<HelloWorldResult>string</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /HandlePatient.asmx HTTP/1.1
Host: 192.168.33.238
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<HelloWorld xmlns="http://tempuri.org/">
<test>string</test>
</HelloWorld>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<HelloWorldResponse xmlns="http://tempuri.org/">
<HelloWorldResult>string</HelloWorldResult>
</HelloWorldResponse>
</soap12:Body>
</soap12:Envelope>
HTTP GET
以下是 HTTP GET 请求和响应示例。所显示的占位符需替换为实际值。
GET /HandlePatient.asmx/HelloWorld?test=string HTTP/1.1
Host: 192.168.33.238
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">string</string>
HTTP POST
以下是 HTTP POST 请求和响应示例。所显示的占位符需替换为实际值。
POST /HandlePatient.asmx/HelloWorld HTTP/1.1
Host: 192.168.33.238
Content-Type: application/x-www-form-urlencoded
Content-Length: length
test=string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">string</string>
delphi代码
procedure TForm1.Button1Click(Sender: TObject);
var
url,inxml,outxml,ErrorMsg,Trade_Id:string;
xmlHttp:Olevariant;
xmldoc:Olevariant;
i,rtrn_code:integer;
doc:IXMLDocument;
node,rootnode:IXMLNODE;
params:string;
xml:TStringStream;
begin
//Trade_Id:='getHospitalInfo';
//url:='http://127.0.0.1:8082/doReqToHis?service=getHospitalInfo';
// inxml:='<?xml version="1.0" encoding="UTF-8"?> '
// +'<request op="HelloWorld">' //接口编号
// +'<aa>00011</aa></request>';
url:=Edit1.Text;
inxml:=Memo1.Text;
try
xmlHttp:=CreateOleObject('MSXML2.XMLHTTP'); //IE的版本不能低于6.0
xmldoc:=CreateOleObject('MSXML.DOMDocument');// 要对对方确定XML的组件的版本
except
showmessage('创建XML组件失败!');
Exit;
end;
try
//调用XMLHTTP组件的方法
//xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
params := 'test='+inxml;
xmlHttp.open('POST',url,false);
xmlhttp.SetRequestHeader ('Content-Type','application/x-www-form-urlencoded');
//xmlhttp.SetRequestHeader ('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);
//延时处理
i:= 0;
while xmlHttp.readystate <> 4 do
begin
i := i+1;
if i > 10000000 then
begin
showmessage('交易失败,已经超出最大延时数!');
Exit;
end;
end;
//获取交易状态码
rtrn_code := xmlHttp.status;
If rtrn_code = 12029 Then
begin
showmessage('服务未启动!');
Exit;
end
else
If rtrn_code = 500 Then
begin
showmessage('内部服务器错误,请重试!');
Exit;
end
else
If rtrn_code <> 200 Then
begin
showmessage('交易执行失败!错误代码|'+inttostr(rtrn_code));
Exit;
end;
//正常交易下的结果
outxml:= xmlHttp.responsetext;
Memo2.Lines.Add(outxml);
finally
xmlHttp := Unassigned;
xmldoc := Unassigned;
end;
end;
在send的时候报

访问无参数的是没有问题的,就是带参数的不知道怎么访问
HelloWorld
测试
若要使用 HTTP POST 协议对操作进行测试,请单击“调用”按钮。
参数 值
test:
SOAP 1.1
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /HandlePatient.asmx HTTP/1.1
Host: 192.168.33.238
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://tempuri.org/HelloWorld"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorld xmlns="http://tempuri.org/">
<test>string</test>
</HelloWorld>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<HelloWorldResponse xmlns="http://tempuri.org/">
<HelloWorldResult>string</HelloWorldResult>
</HelloWorldResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2
以下是 SOAP 1.2 请求和响应示例。所显示的占位符需替换为实际值。
POST /HandlePatient.asmx HTTP/1.1
Host: 192.168.33.238
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<HelloWorld xmlns="http://tempuri.org/">
<test>string</test>
</HelloWorld>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<HelloWorldResponse xmlns="http://tempuri.org/">
<HelloWorldResult>string</HelloWorldResult>
</HelloWorldResponse>
</soap12:Body>
</soap12:Envelope>
HTTP GET
以下是 HTTP GET 请求和响应示例。所显示的占位符需替换为实际值。
GET /HandlePatient.asmx/HelloWorld?test=string HTTP/1.1
Host: 192.168.33.238
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">string</string>
HTTP POST
以下是 HTTP POST 请求和响应示例。所显示的占位符需替换为实际值。
POST /HandlePatient.asmx/HelloWorld HTTP/1.1
Host: 192.168.33.238
Content-Type: application/x-www-form-urlencoded
Content-Length: length
test=string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">string</string>
delphi代码
procedure TForm1.Button1Click(Sender: TObject);
var
url,inxml,outxml,ErrorMsg,Trade_Id:string;
xmlHttp:Olevariant;
xmldoc:Olevariant;
i,rtrn_code:integer;
doc:IXMLDocument;
node,rootnode:IXMLNODE;
params:string;
xml:TStringStream;
begin
//Trade_Id:='getHospitalInfo';
//url:='http://127.0.0.1:8082/doReqToHis?service=getHospitalInfo';
// inxml:='<?xml version="1.0" encoding="UTF-8"?> '
// +'<request op="HelloWorld">' //接口编号
// +'<aa>00011</aa></request>';
url:=Edit1.Text;
inxml:=Memo1.Text;
try
xmlHttp:=CreateOleObject('MSXML2.XMLHTTP'); //IE的版本不能低于6.0
xmldoc:=CreateOleObject('MSXML.DOMDocument');// 要对对方确定XML的组件的版本
except
showmessage('创建XML组件失败!');
Exit;
end;
try
//调用XMLHTTP组件的方法
//xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
params := 'test='+inxml;
xmlHttp.open('POST',url,false);
xmlhttp.SetRequestHeader ('Content-Type','application/x-www-form-urlencoded');
//xmlhttp.SetRequestHeader ('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);
//延时处理
i:= 0;
while xmlHttp.readystate <> 4 do
begin
i := i+1;
if i > 10000000 then
begin
showmessage('交易失败,已经超出最大延时数!');
Exit;
end;
end;
//获取交易状态码
rtrn_code := xmlHttp.status;
If rtrn_code = 12029 Then
begin
showmessage('服务未启动!');
Exit;
end
else
If rtrn_code = 500 Then
begin
showmessage('内部服务器错误,请重试!');
Exit;
end
else
If rtrn_code <> 200 Then
begin
showmessage('交易执行失败!错误代码|'+inttostr(rtrn_code));
Exit;
end;
//正常交易下的结果
outxml:= xmlHttp.responsetext;
Memo2.Lines.Add(outxml);
finally
xmlHttp := Unassigned;
xmldoc := Unassigned;
end;
end;
在send的时候报

访问无参数的是没有问题的,就是带参数的不知道怎么访问
...全文
相关推荐
电子商务案例分析(第七版)课程标准+课件+教案+试卷及答案
电子商务案例分析(第七版)课程标准+课件+教案+试卷及答案
政府科技管理者在审批科技成果转化项目时,如何高效核实技术成果的知识产权归属?.docx
政府科技管理者在审批科技成果转化项目时,如何高效核实技术成果的知识产权归属?
技术经理人上岗后成长慢?AI工具打造从上手到出活的全链路支撑.docx
技术经理人上岗后成长慢?AI工具打造从上手到出活的全链路支撑
数媒大赛ai工具使用word说明
数媒大赛ai工具使用word说明
任意波形发生器 (AWG):高速化、宽带化与软件定义加速演进,任意波形发生器迎来量子、先进通信与半导体测试新机遇.docx
任意波形发生器 (AWG):高速化、宽带化与软件定义加速演进,任意波形发生器迎来量子、先进通信与半导体测试新机遇


Windows SDK/API
