線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:3188
推到 Plurk!
推到 Facebook!

delphi调用Java的Webservice出现问题!

缺席
hnlg81004
一般會員


發表:5
回覆:7
積分:2
註冊:2005-02-16

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-03-25 23:15:38 IP:220.242.xxx.xxx 訂閱
以下是部分导入wsdl后生成的代码:
ArrayOfString = array of WideString; { "urn:epcglobal:ale:wsdl:1" }
GetECSpecNamesResult = ArrayOfString; { "urn:epcglobal:ale:wsdl:1"[L] }

EmptyParms = class(TRemotable)
private
public
constructor Create; override;
published
end;

GetECSpecNames = EmptyParms; { "urn:epcglobal:ale:wsdl:1"[L] }
GetStandardVersion = EmptyParms; { "urn:epcglobal:ale:wsdl:1"[L] }
GetStandardVersionResult = type WideString; { "urn:epcglobal:ale:wsdl:1"[L] }

GetVendorVersion = EmptyParms; { "urn:epcglobal:ale:wsdl:1"[L] }
GetVendorVersionResult = type WideString; { "urn:epcglobal:ale:wsdl:1"[L] }

ALEServicePortType = interface(IInvokable)
['{89261E5F-CB3D-B520-AB70-8D333AB656C3}']
function getECSpecNames(const parms: GetECSpecNames): GetECSpecNamesResult; stdcall;
function getStandardVersion(const parms: GetStandardVersion): GetStandardVersionResult; stdcall;
function getVendorVersion(const parms: GetVendorVersion): GetVendorVersionResult; stdcall;

initialization
InvRegistry.RegisterInterface(TypeInfo(ALEServicePortType), 'urn:epcglobal:ale:wsdl:1', 'UTF-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ALEServicePortType), '');
InvRegistry.RegisterInvokeOptions(TypeInfo(ALEServicePortType), ioDocument);
InvRegistry.RegisterInvokeOptions(TypeInfo(ALEServicePortType), ioLiteral);
RemClassRegistry.RegisterXSInfo(TypeInfo(GetECSpecNames), 'urn:epcglobal:ale:wsdl:1', 'GetECSpecNames');
RemClassRegistry.RegisterXSInfo(TypeInfo(GetStandardVersion), 'urn:epcglobal:ale:wsdl:1', 'GetStandardVersion');
RemClassRegistry.RegisterXSInfo(TypeInfo(GetStandardVersionResult), 'urn:epcglobal:ale:wsdl:1', 'GetStandardVersionResult');
RemClassRegistry.RegisterXSInfo(TypeInfo(GetSubscribersResult), 'urn:epcglobal:ale:wsdl:1', 'GetSubscribersResult');
.....
下面是调用的代码:
procedure TForm1.btn1Click(Sender: TObject);
var
iface: ALEServicePortType;
emp: EmptyParms;
names: ArrayOfString;
i: Integer;
gsv: GetStandardVersion;
begin
iface := (HttpRIO1 as ALEServicePortType);
emp := EmptyParms.Create;
mmo1.Lines.Clear;
names:=iface.getECSpecNames(emp);
for i:=Low(names) to High(names) do
begin
mmo1.Lines.Add(names[i]);
end;
{mmo1.Lines.Clear;
gsv:=EmptyParms.Create;
r:=iface.getStandardVersion(gsv);
mmo1.Lines.Add(r); }
end;
procedure TForm1.HTTPRIO1BeforeExecute(const MethodName: String;
var SOAPRequest: WideString);
begin
mmo1.Lines.Add(MethodName);
mmo1.Lines.Add(SOAPRequest);
end;
procedure TForm1.HTTPRIO1AfterExecute(const MethodName: String;
SOAPResponse: TStream);
begin
mmo2.Lines.Add(MethodName);
SOAPResponse.Position:=0;
mmo2.Lines.LoadFromStream(SOAPResponse);
SOAPResponse.Position:=0;
end;

如果是调用getECSpecNames函数的话mmo1返回:
getECSpecNames
<?xml version="1.0"?>
http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns="urn:epcglobal:ale:wsdl:1"/>
TEST //函数返回结果,正确的.

mmo2返回:
http://schemas.xmlsoap.org/soap/envelope/
" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns:ns1="urn:epcglobal:ale:wsdl:1">TEST

如果是调用getStandardVersion函数
mmo1返回:
getStandardVersion
<?xml version="1.0"?>
http://schemas.xmlsoap.org/soap/envelope/
" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns="urn:epcglobal:ale:wsdl:1"/>
http://schemas.xmlsoap.org/soap/envelope/
" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns:ns1="urn:epcglobal:ale:wsdl:1">TEST
为什么调用getStandardVersion函数的时候在BeforeExecute事件里SOAP Body还是传的GetECSpecNames方法呢?实在费解..
系統時間:2024-11-21 22:01:28
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!