1、WSDL单元中函数: 1)、function BatchTakeTicket(const arg0: string; const arg1: string; const arg2: Array_Of_mapEntry; const arg3: string; const arg4: string): getTakeTicketResult; stdcall; 2)、函数中的参数:const arg2: Array_Of_mapEntry; mapEntry = class(TRemotable) private Fkey: string; Fkey_Specified: boolean; Fvalue: string; Fvalue_Specified: boolean; procedure Setkey(Index: Integer; const Astring: string); function key_Specified(Index: Integer): boolean; procedure Setvalue(Index: Integer; const Astring: string); function value_Specified(Index: Integer): boolean; published property key: string Index (IS_OPTN or IS_UNQL) read Fkey write Setkey stored key_Specified; property value: string Index (IS_OPTN or IS_UNQL) read Fvalue write Setvalue stored value_Specified; end;
Array_Of_mapEntry = array of mapEntry; 4、我的代码: .......... var getTakeTicketResponse :getTakeTicketResult; i,iRecord : integer; OfmapEntry :Array_Of_mapEntry; //Array_Of_mapEntry begin .......... for i := 0 to iRecord - 1 do begin OfmapEntry[i] := mapEntry.Create; //创建类 OfmapEntry[i].key := intTostr(i); OfmapEntry[i].value :=subMapinfo[i].orderId; end; //调用WSDL中函数: getTakeTicketResponse := GetAttachService(subCommInfo.urAdd).BatchTakeTicket( subCommInfo.userName, subCommInfo.userPwd, OfmapEntry, subCommInfo.operatorCode, subCommInfo.operatorName); //执行完后,报错:Invalid number of payload elements:2, ....... end; 5、在执行函数时,出现错误如下:Invalid number of payload elements:2, 研究了好的天,不知错误在哪里?请专家指教,谢谢了。
你应该已经把wsdl文件转成pas文件了吧,
调用webservice中的方法没有什么特别的呀,仔细检查一下类,对象是否创建、参数是否正确。
说一下服务端是用什么开发的?怎么部署的?如果你用Delphi开发服务端,用Delphi做客户端来调用,而且Delphi的版本都一致,是不会有问题的。但是Delphi做的WebService客户端调用Java或C#等工具开发的WebService服务端时会出现soap协议不一致的问题。我以前遇到过这种问题,Soap2.0协议变化很大,而且不向下兼容。解决的方式是使用DelphiXE开发客户端,或用HTTP 协议自己解析xml内容。