请教高手:delphi调用Web,返回TByteDynArray,错误:SOAP Response Packet: result element (在线等回复)
delphi调用Web,返回TByteDynArray,
错误:SOAP Response Packet: result element expected,received"<GetPhotoResponse xmlns="http://127.0.0.1/Test"/>"
WSDL IMPORTER
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://10.27.17.26:8080/webservice.asmx?wsdl
// Encoding : utf-8
// Codegen : [wfDebug,wfUseSerializerClassForAttrs]
// Version : 1.0
// (2010-4-21 19:41:09 - 1.33.2.5)
// ************************************************************************ //
unit webservice;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns,Classes;
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 Borland 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"
// !:int - "http://www.w3.org/2001/XMLSchema"
// !:base64Binary - "http://www.w3.org/2001/XMLSchema"
GetExamSiteResult = class; { "http://127.0.0.1/TEST" }
GetExamTodayDataSetResult = class; { "http://127.0.0.1/TEST" }
// ************************************************************************ //
// Namespace : http://127.0.0.1/TEST
// ************************************************************************ //
GetExamSiteResult = class(TRemotable)
private
Fschema: WideString;
published
property schema: WideString read Fschema write Fschema;
end;
// ************************************************************************ //
// Namespace : http://127.0.0.1/TEST
// ************************************************************************ //
GetExamTodayDataSetResult = class(TRemotable)
private
Fschema: WideString;
published
property schema: WideString read Fschema write Fschema;
end;
// ************************************************************************ //
// Namespace : http://127.0.0.1/TEST
// soapAction: http://127.0.0.1/TEST/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// binding : WebServiceSoap
// service : WebService
// port : WebServiceSoap
// URL : http://192.168.1.254:8080/webservice.asmx
// ************************************************************************ //
WebServiceSoap = interface(IInvokable)
['{E1CC57AD-4355-2FB3-D0CE-B503C1F049D3}']
function GetExamSite(const bm1: WideString; const bm2: WideString): GetExamSiteResult; stdcall;
function GetExamTodayDataSet(const bm1: WideString; const bm2: WideString; const bm3: WideString): string; stdcall;
function GetPhoto(const bm1: WideString; const bm2: WideString; const bm3: WideString): TByteDynArray; stdcall;
end;
function GetWebServiceSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): WebServiceSoap;
implementation
function GetWebServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): WebServiceSoap;
const
defWSDL = 'http://168.192.253.100:8080/webservice.asmx?wsdl';
defURL = 'http://168.192.253.100:8080/webservice.asmx';
defSvc = 'WebService';
defPrt = 'WebServiceSoap';
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 WebServiceSoap);
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
InvRegistry.RegisterInterface(TypeInfo(WebServiceSoap), 'http://127.0.0.1/TEST', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(WebServiceSoap), 'http://127.0.0.1/TEST/%operationName%');
RemClassRegistry.RegisterXSClass(GetExamSiteResult, 'http://127.0.0.1/TEST', 'GetExamSiteResult');
RemClassRegistry.RegisterXSClass(GetExamTodayDataSetResult, 'http://127.0.0.1/TEST', 'GetExamTodayDataSetResult');
InvRegistry.RegisterInvokeOptions(TypeInfo(WebServiceSoap), ioDocument);
end.
客户端调用代码
procedure TMainForm.b_ChaXunClick(Sender: TObject);
var i,len:integer;
zpByte:TByteDynArray;
tmpstream:TMemorystream;
begin
DeleteFile('c:\xp.jpg');
zpImg.Picture:=nil;
tmpstream:=TMemorystream.Create;
try
zpByte:=(HTTPRIO1 as WebServiceSoap).GetPhoto(Str1,Str1,Str1);//Str1,Str1,Str1已赋值,类型是String
except
tmpstream.Free;
exit;
end;
len:= length(zpByte);
for i:=0 to len-1 do
tmpstream.Write(zpByte[i],sizeof(zpByte[i]));
tmpstream.SaveToFile('c:\xp.jpg');
if FileExists('c:\xp.jpg') then
zpImg.Picture.LoadFromFile('c:\xp.jpg');
tmpstream.Free;
end;
报错位置
try
zpByte:=(HTTPRIO1 as WebServiceSoap).GetPhoto(Str1,Str1,Str1);