delphi多线程调用webservice的问题,非常着急。

sinopf 2010-01-27 09:31:08
function getbook:Integer;stdcall;
var
WsObj:HosServicePortType;
begin
try
CoInitialize(Nil);
WsObj:=MainForm.HTTPRIO1 as HosServicePortType;//引用Mainform上的HTTPRIO控件
WsArray:=WsObj.getBook('0371001','20100302');//发送请求(getbook是webservice中的函数)
finally
CoUninitialize;
end;
Result:=0;
end;
。。。。省略
procedure TMainForm.FormShow(Sender: TObject);
var i:Integer;
ARegistry:TRegistry;
ID: DWORD;
begin
hThread := CreateThread(nil, 0, @getbook, nil,0, ID);//这样产生进程
......省略


我想在线程中实线后台自动发送请求,但是一直提示错误:

Thread Start: Thread ID: 1732. Process HosClient.exe (3436)
First chance exception at $7C812AFB. Exception class ESOAPHTTPException with message 'The handle is in the wrong state for the requested operation - URL:http://192.168.0.100:8080/crm_pt/service/HosService?wsdl - SOAPAction:""'. Process HosClient.exe (3436)

不知道什么原因,我刚开始学习线程,网上查了很多资料都学不来~请求帮助。
...全文
257 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
lhy 2010-01-27
  • 打赏
  • 举报
回复
访问VCL时用Synchronize
buding79 2010-01-27
  • 打赏
  • 举报
回复
我感觉你最好写一个独立的线程,那样好处理一些。
brightyang 2010-01-27
  • 打赏
  • 举报
回复
设置临界区

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧