xe2调用 webservice接口 运行时间一长就报异常,无法分配更多Internet句柄

a735208362 2017-06-02 10:39:13
程序运行长时间之后接口调用的地方就会开始报异常,
报错的详细信息如下:
Unable to load WSDL File/Location: http://localhost:8080/InterFaceService/service/InterFaceService?wsdl. Error [无法分配更多的 Internet 句柄 - URL:http://localhost:8080/InterFaceService/service/InterFaceService?wsdl - SOAPAction:""]"/>

接口源代码:
unit InterFaceService;

interface

uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

type

// ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// to but never[!] declared in the document. The types from the latter category
// typically map to predefined/known XML or Embarcadero types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema"[]


// ************************************************************************ //
// Namespace : interface
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// use : encoded
// binding : InterFaceServiceSoapBinding
// service : InterFaceBeanService
// port : InterFaceService
// URL : http://localhost:8080/InterFaceService/service/InterFaceService
// ************************************************************************ //
InterFaceBean = interface(IInvokable)
['{54258081-E132-7265-9562-CB0F456F6FC2}']
function interFace_(const strYwdm: string; const strXml: string; const strMd5: string): string; stdcall;
end;

function GetInterFaceBean(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): InterFaceBean;


implementation
uses SysUtils;

function GetInterFaceBean(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): InterFaceBean;
const
defWSDL = 'http://localhost:8080/InterFaceService/service/InterFaceService?wsdl';
defURL = 'http://localhost:8080/InterFaceService/service/InterFaceService';
defSvc = 'InterFaceBeanService';
defPrt = 'InterFaceService';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
if HTTPRIO = nil then
RIO := THTTPRIO.Create(nil)
else
RIO := HTTPRIO;
try
Result := (RIO as InterFaceBean);
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;


initialization
{ InterFaceBean }
InvRegistry.RegisterInterface(TypeInfo(InterFaceBean), 'interface', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(InterFaceBean), '');
{ InterFaceBean.interFace_ }
InvRegistry.RegisterMethodInfo(TypeInfo(InterFaceBean), 'interFace_', 'interFace', '');

end.


调用代码:
function YWVerification(ABarcode,ASeqID: WideString; out FailMsg: WideString): WideString;
var
vFunc: InterFaceBean;
vXml: TXMLDocument;
vRoot,vNode: IXMLNode;
tmpComp: TComponent;
vSendstr,vRes: string;
begin
Result:='';
if ABarcode='' then
begin
FailMsg:='传入条码号为空';
Exit;
end;
if ASeqID='' then
begin
FailMsg:= '验证流水号为空';
Exit;
end;
tmpComp:= TComponent.Create(nil);
vXml:= TXMLDocument.Create(tmpComp);
try
try
vFunc:= GetInterFaceBean(True,'http://localhost:8080/InterFaceService/service/InterFaceService?wsdl');
vXml.Active:= True;
vXml.Version:='1.0';
vXml.Encoding:='UTF-8';
vRoot:= vXml.AddChild('xml');
vNode:= vRoot.AddChild('parm');
vNode.NodeValue:= ABarcode;
vNode:= vRoot.AddChild('parm');
vNode.NodeValue:= ASeqID;
vSendstr:= vXml.XML.Text;

vRes:= vFunc.interFace_('human_004',vSendstr,'l9PW1eO8HLU=');
if vRes='' then
begin
FailMsg:='调用接口失败,返回空';
Exit;
end;
Result:= UTF8Encode(vRes);
except
on e:Exception do
begin
FailMsg:='调用YWVerification发生异常:'+ e.Message;
end;
end;
finally
vXml.Free;
tmpComp.Free;
end;
end;
...全文
1559 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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