请教高手:delphi调用Web,返回TByteDynArray,错误:SOAP Response Packet: result element (在线等回复)

mxf_sltec 2011-12-04 10:45:45
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);
...全文
471 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
# GNS3概述       GNS3 是一款具有图形化界面、可以运行在多平台(包括Windows, Linux和Mac OS等)上的网络虚拟软件。该软件能够在计算机上虚拟出思科路由器和交换机的硬件,且加载思科路由器和交换机的IOS(真实模拟),通过它可以体验 Cisco 网际操作系统 IOS或检验将要在真实的路山器上部署实施的相关配置。       Cisco 网络设备管理员或是想要通过 CCNA、CCNP、CCIE等Cisco认证考试的相关人士可以通过它来完成相关的实验;同时让我们体验和真实路由器和交换机完全一样的学习过程,在某些方面比真实设备的功能还要强大。       所以 GNS3 对于我们学习计算机网络原理的学生,也是必不可少的工具。# VMWare Workstation       桌面级虚拟化产品,大名鼎鼎,不言而喻。# Wireshark 抓包工具       本章还演示了在GNS3搭建的网络环境,使用Wireshark抓包工具捕获数据包,可以捕获网络拓扑中任意链路上通过的数据包,为学习后面的章节打下坚实的基础。# SecureCRT       连接、操作和管理 GNS3 的强大功能软件,之前Linux教学中已经详细介绍使用。# PacketTracer       思科路由器交换机模拟软件,Packet Tracer 是由Cisco公司发布的一个辅助学习工具,为学习CCNA课程的网络‘初学者’设计、配置、排除网络故障提供了网络模拟环境。学生可在软件的图形用户界面上直接使用拖曳方法建立网络拓扑,软件中实现的IOS子集允许学生配置设备;并可提供数据包在网络中行进的详细处理过程,观察网络实时运行情况。 # 重点提示       本章不属于计算机网络原理的内容,但要想更好地理解后面讲到的计算机网络原理,更具体地探索计算机通信过程,还需要捕获数据包、分析数据包的数据链路层首部、网络层首部、传输层首部以及应用层协议,这就需要使用网络设备来搭建学习环境。

1,593

社区成员

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

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