SOAP SERVER 接口中执行的存储过程出错(50)

Z

zhengxd

Unregistered / Unconfirmed
GUEST, unregistred user!
最近遇到一个新问题,客户端通过接口函数,传递参数给SOAP server 执行存储过程往数据库中写数据不成功。请帮忙看一下,代码如下:服务器端代码Unit DiaoData1;interfaceuses SysUtils, Classes, InvokeRegistry, Midas, SOAPMidas, SOAPDm, DB, ADODB;type TDaywidestringarray=array of Widestring;
IdiaoSoap1 = interface(IAppServerSOAP) ['{809114F2-605A-4BC2-ABAE-AF4209A7535B}'] function samll_codePost(const str: TDaywidestringarray;s:integer):string;stdcall;
end;
TdiaoSoap1 = class(TSoapDataModule, IdiaoSoap1, IAppServerSOAP, IAppServer) ADOConnection1: TADOConnection;
yc_insert_SmallCode1: TADOStoredProc;
yc_insert_BigCode: TADOStoredProc;
private public function samll_codePost(const str: TDaywidestringarray;s:integer):string;stdcall;
end;
implementation{$R *.DFM}procedure TdiaoSoap1CreateInstance(out obj: TObject);
begin
obj := TdiaoSoap1.Create(nil);
end;
function TdiaoSoap1.samll_codePost(const str: TDaywidestringarray;s:integer):string;stdcall;
begin
if s=1 then
begin
ADOConnection1.begin
Trans;
TRY with yc_insert_SmallCode1do
begin
close;
Parameters.ParamValues['@Mft_code']:=str[0];
Parameters.ParamValues['@ParentCode']:=str[1];
Parameters.ParamValues['@CurCode']:=str[2];
Parameters.ParamValues['@strFileName']:=str[3];
ExecProc;
end;
ADOConnection1.CommitTrans;
result:='1';
EXCEPT ADOConnection1.RollbackTrans;
result:='0';
end;
end;
if S=2 then
begin
ADOConnection1.begin
Trans;
TRY with yc_insert_BigCodedo
begin
close;
Parameters.ParamValues['@Mft_code']:=str[0];
Parameters.ParamValues['@mft_date']:=str[1];
Parameters.ParamValues['@Volum_number']:=str[2];
Parameters.ParamValues['@order_no']:=str[3];
Parameters.ParamValues['@strFileName']:=str[4];
ExecProc;
end;
ADOConnection1.CommitTrans;
result:='1';
EXCEPT ADOConnection1.RollbackTrans;
result:='0';
end;
end;
//if s=2 执行存储过程 yc_insert_BigCodeend;
initialization InvRegistry.RegisterInvokableClass(TdiaoSoap1, TdiaoSoap1CreateInstance);
InvRegistry.RegisterInterface(TypeInfo(IdiaoSoap1));
end.
客户端代码procedure TBigCodeTRForm.BitBtn2Click(Sender: TObject);var mm_zJs:integer;
mm_count:integer;
mm_order:string;
mm_cpcode:string;
mm_mft_date:string;
mm_volum_number:string;
mm_string:string;
str:string;
str1:TDaywidestringarray;
aIntf:IdiaoSoap1;
begin
if self.bsSkinMessage1.MessageDlg('真得确认导入此文件数据吗?',(mtInformation),[mbYES,mbNO],0)=IDYES then
begin
BitBtn1.Enabled:=False;
BitBtn2.Enabled:=False;
BitBtn3.Enabled:=False;
aIntf:=HTTPRIO1 AS IdiaoSoap1;
setLength(str1,5);
mm_string:=TRIM(self.Memo1.Lines.Strings[0]);
mm_count:=self.Memo1.Lines.Count;
//总行数 if mm_string='Type=Market' then
//符合要求的文件格式 begin
mm_string:=TRIM(self.Memo1.Lines.Strings[1]);
mm_mft_date:=copy(mm_string,6,length(mm_string)-5);//取出扫码日期 bsSkinGauge1.ProgressText:='开始导入数据......';
bsSkinGauge1.MaxValue:=mm_count-3;
bsSkinGauge1.Value:=0;
FOR mm_Zjs:=3 TO mm_countdo
//去掉文件头,从第4行开始取数 begin
mm_string:=TRIM(self.Memo1.Lines.Strings[mm_zJs]);
if mm_string='OrderNo=' then
//取订单号 ,取商品代码 begin
mm_string:=TRIM(self.Memo1.Lines.Strings[mm_zJs+1]);
//取订单号 mm_order:=copy(mm_string,3,length(mm_string)-2);
mm_string:=TRIM(self.Memo1.Lines.Strings[mm_zJs+2]);
//取商品代码 mm_cpcode:=copy(mm_string,3,length(mm_string)-2);
mm_string:=TRIM(self.Memo1.Lines.Strings[mm_zJs]);//重新取回到当前行 end;
if (length(mm_string)=14) and (copy(mm_string,2,1)<>'=') then
//如果字符串长14 并且第2位不是=号 //则判断为是正常物流码 ,并向数据库提交数据 begin
mm_volum_number:=mm_string;//取出物流码 str1[0]:=mm_cpcode;
str1[1]:=mm_mft_date;
str1[2]:=mm_volum_number;
str1[3]:=mm_order;
str1[4]:=mm_FileName;
str:= aIntf.samll_codePost(str1,2);
end;
bsSkinGauge1.Value:=mm_Zjs;
bsSkinGauge1.ProgressText:='已完成 '+FloatTostr(mainform.x_round(mm_Zjs/(mm_count-3)*100))+'%';
end;
//取每一行文字进行处理 bsSkinGauge1.Value:=0;
bsSkinGauge1.ProgressText:='转换完毕!';
if str='1' then
self.bsSkinMessage1.MessageDlg('文件已成功导入!',(mtInformation),[mbOK],0) else
self.bsSkinMessage1.MessageDlg('文件导入失败,请完成后再试一次!',(mtError),[mbOK],0);
end //判断文件是否符合要求 else
begin
self.bsSkinMessage1.MessageDlg('选定文件格式不符合要求,请重新选定文件后再试!',(mtError),[mbOK],0);
BitBtn1.Enabled:=TRUE;
BitBtn2.Enabled:=False;
BitBtn3.Enabled:=True;
end;
BitBtn1.Enabled:=TRUE;
BitBtn2.Enabled:=TRUE;
BitBtn3.Enabled:=True;
end;
//是否确认导入文件end;
第一个 S=1 存储过程没有错误,能成功执行,第二个 S=2 存储过程不能往数据库写,存储过程在C/S结构中能执行。
 

傻二

Unregistered / Unconfirmed
GUEST, unregistred user!
写的不错么,你的存储过程参数干么不释放
 

傻二

Unregistered / Unconfirmed
GUEST, unregistred user!
试试动态创建参数然后释放或者动态创建 ADOConnection1: TADOConnection;
yc_insert_SmallCode1: TADOStoredProc;
yc_insert_BigCode: TADOStoredProc;然后释放
 
Z

zhengxd

Unregistered / Unconfirmed
GUEST, unregistred user!
上问题已自行解决,另一个问题是:如果接口中存储过程参数为日期型,从客户端传来日期型字符串赋给该参数,存储过程出错,如:'2010-06-25'。在C/S结构中不会出错,是否Delphi7的SOAP也存在Bug? 据我所知,Delphi6的SOAP中是存在Bug的。
 

Similar threads

S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
895
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
顶部