小弟第一次发帖,查了好多资料都弄不明白,望高手们多指点:
delphi程序调用报告如下异常:
defWSDL = 'http://192.168.0.1:8080/LCardService/HighWay?wsdl';自动生成代码如下:
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL     : http://192.168.0.1:8080/LCardService/HighWay?wsdl
//  >Import : http://192.168.0.1:8080/LCardService/HighWay?wsdl=IHighWay.wsdl
// Encoding : UTF-8
// Version  : 1.0
// (2013-4-25 15:09:51 - 1.33.2.5)
// ************************************************************************ //unit HighWay;interfaceuses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;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"
  // !:base64Binary    - "http://www.w3.org/2001/XMLSchema"  upLoadPicResponse    = class;                 { "http://business.subservice.xds.ihe.neusoft.com/" }
  doServiceResponse    = class;                 { "http://business.subservice.xds.ihe.neusoft.com/" }
  doServiceExtResponse = class;                 { "http://business.subservice.xds.ihe.neusoft.com/" }
  doService            = class;                 { "http://business.subservice.xds.ihe.neusoft.com/" }
  upLoadPic            = class;                 { "http://business.subservice.xds.ihe.neusoft.com/" }
  doServiceExt         = class;                 { "http://business.subservice.xds.ihe.neusoft.com/" }  // ************************************************************************ //
  // Namespace : http://business.subservice.xds.ihe.neusoft.com/
  // ************************************************************************ //
  upLoadPicResponse = class(TRemotable)
  private
    Freturn: WideString;
  published
    property return: WideString read Freturn write Freturn;
  end;  // ************************************************************************ //
  // Namespace : http://business.subservice.xds.ihe.neusoft.com/
  // ************************************************************************ //
  doServiceResponse = class(TRemotable)
  private
    Freturn: WideString;
  published
    property return: WideString read Freturn write Freturn;
  end;  // ************************************************************************ //
  // Namespace : http://business.subservice.xds.ihe.neusoft.com/
  // ************************************************************************ //
  doServiceExtResponse = class(TRemotable)
  private
    Freturn: WideString;
  published
    property return: WideString read Freturn write Freturn;
  end;  // ************************************************************************ //
  // Namespace : http://business.subservice.xds.ihe.neusoft.com/
  // ************************************************************************ //
  doService = class(TRemotable)
  private
    Farg0: WideString;
  published
    property arg0: WideString read Farg0 write Farg0;
  end;  // ************************************************************************ //
  // Namespace : http://business.subservice.xds.ihe.neusoft.com/
  // ************************************************************************ //
  upLoadPic = class(TRemotable)
  private
    Farg0: TByteDynArray;
  published
    property arg0: TByteDynArray read Farg0 write Farg0;
  end;  // ************************************************************************ //
  // Namespace : http://business.subservice.xds.ihe.neusoft.com/
  // ************************************************************************ //
  doServiceExt = class(TRemotable)
  private
    Farg0: WideString;
    Farg1: TByteDynArray;
  published
    property arg0: WideString read Farg0 write Farg0;
    property arg1: TByteDynArray read Farg1 write Farg1;
  end;
  // ************************************************************************ //
  // Namespace : http://business.subservice.xds.ihe.neusoft.com/
  // binding   : HighWaySoapBinding
  // service   : HighWay
  // port      : HighWayImplPort
  // URL       : http://192.168.0.1:8080/LCardService/HighWay
  // ************************************************************************ //
  IHighWay = interface(IInvokable)
  ['{53F3A949-B88F-F51D-0FFC-EC7B0D7E8D03}']
    function  doServiceExt(const parameters: doServiceExt): doServiceExtResponse; stdcall;
    function  doService(const parameters: doService): doServiceResponse; stdcall;
    function  upLoadPic(const parameters: upLoadPic): upLoadPicResponse; stdcall;
  end;function GetIHighWay(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): IHighWay;
implementationfunction GetIHighWay(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): IHighWay;
const
  defWSDL = 'http://192.168.0.1:8080/LCardService/HighWay?wsdl';
  defURL  = 'http://192.168.0.1:8080/LCardService/HighWay';
  defSvc  = 'HighWay';
  defPrt  = 'HighWayImplPort';
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 IHighWay);
    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(IHighWay), 'http://business.subservice.xds.ihe.neusoft.com/', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(IHighWay), '');
//  InvRegistry.RegisterInvokeOptions(TypeInfo(IHighWay),ioDocument);
  RemClassRegistry.RegisterXSClass(upLoadPicResponse, 'http://business.subservice.xds.ihe.neusoft.com/', 'upLoadPicResponse');
  RemClassRegistry.RegisterXSClass(doServiceResponse, 'http://business.subservice.xds.ihe.neusoft.com/', 'doServiceResponse');
  RemClassRegistry.RegisterXSClass(doServiceExtResponse, 'http://business.subservice.xds.ihe.neusoft.com/', 'doServiceExtResponse');
  RemClassRegistry.RegisterXSClass(doService, 'http://business.subservice.xds.ihe.neusoft.com/', 'doService');
  RemClassRegistry.RegisterXSClass(upLoadPic, 'http://business.subservice.xds.ihe.neusoft.com/', 'upLoadPic');
  RemClassRegistry.RegisterXSClass(doServiceExt, 'http://business.subservice.xds.ihe.neusoft.com/', 'doServiceExt');end.调用函数如下:unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, InvokeRegistry, StdCtrls, Rio, SOAPHTTPClient,highway;type
  TForm1 = class(TForm)
    HTTPRIO1: THTTPRIO;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
        procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
 var
doServiceRes :doServiceResponse;
doSer :doService;
lIntf:IHighWay;
DataCon: TDataContext;
DataCon1: TinvCONTEXT;
bb:Pointer;
_contex2 : WideString;
CC: longint;
s:string;begin _contex2 := '<?xml version="1.0" encoding="utf-8" standalone="yes"?> '
            + '<neuMessage>'
            + '<head>'
            + '<businessType>P0002</businessType>'
            + '<sendTime>20130220134559</sendTime>'
            + '<sendNum>p000120130220134559</sendNum>'
            + '<returnNum></returnNum>'
            + '<areaCode>210100</areaCode>'
            + '<sendOrgName>?1?</sendOrgName>'
            + '<resFlag></resFlag>'
            + '<resMessage></resMessage>'
            + '</head>'
            + '<body>'
            + '<baseResidentsInfo>'
            + '<ddf1ef06_0001>??</ddf1ef06_0001>'
            + '<ddf1df01ef08_0001>1</ddf1df01ef08_0001>'
            + '<ddf1ef06_0005>210724195412055624</ddf1ef06_0005>'
            + '</baseResidentsInfo>'
            + '</body>'
            + '</neuMessage>'; doSer := doService.Create  ;  doser.arg0 := _contex2;
  lIntf := (HTTPRIO1 as IHighWay);  doServiceRes := getIhighWay.doService(doser);
  DataCon1.Destroy ;
  //Result := false;end;//Form 初始化
procedure TForm1.FormCreate(Sender: TObject);
begin
  HTTPRIO1.WSDLLocation := 'http://192.168.0.1:8080/LCardService/HighWay?wsdl';
  HTTPRIO1.Service := 'HighWay';
  HTTPRIO1.Port := 'HighWayImplPort';
end;end.Delphi

解决方案 »

  1.   

    在调用到
    doServiceRes := getIhighWay.doService(doser);
    时候报的错误在线等哦
      

  2.   

    getIhighWay.doService(doser);你不觉得这个引用是有问题的吗?换成doSer.doService(doser);这个试一下
      

  3.   


    doSer.后面没有doService高手们再给看看
      

  4.   

    说错了,用lIntf.doService(doser);这个试一下,
      

  5.   


    最开始用的是lIntf,不行,同样的错误,就换了getIhighWay
      

  6.   

    那就是这个转换有问题, lIntf := (HTTPRIO1 as IHighWay);HTTPRIO1 这个对象不是IHighWay类型的;
    你对象创建错了
      

  7.   


    HTTPRIO1是加的一个组件,那应该怎么创建呢?
      

  8.   

    通过这个函数创建
    function GetIHighWay(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): IHighWay;
      

  9.   


    好像也不是这个问题,我这个是比照着天气预报的例子写的,天气预报例子这样写没有问题,如下
    lIntf := (HTTPRIO1 as WeatherWSSoap);我觉得应该是参数的问题,不知道这个参数怎么传,还有可能是ioDocument问题,但不知道怎么解决
      

  10.   

    你获取的是远程对象和天气预报不是一回事,这个是WebService开发的知识,网上也有,你这样引用是有问题的 
      

  11.   


    试了,用
      lIntf := getIhighWay( false, 'http://192.168.0.1:8080/LCardService/HighWay?wsdl', nil);
      lIntf.doService( doser );报了同样的错误
      

  12.   

    这个应该就是个WEBSERVICE,很容易的。
      

  13.   

    这一步成功了没 lIntf := getIhighWay( false, 'http://192.168.0.1:8080/LCardService/HighWay?wsdl', nil);
      

  14.   



    try
    lIntf.doService(doser);
    except
    end;
    这个试一下
      

  15.   

    这个成功了,后面执行
    lIntf.doService( doser );
    就报最开始图的错误了
      

  16.   

    我觉得你应该先做一个简单的接口调用一下,看看是传参的问题,还是接口调用的问题。我觉得对象创建成功了,webservic应该是不会有问题的,要有问题可能是你传递的参数不正确。
      

  17.   

     
    应该是参数不正确,可是这个doservice参数应该怎么传递呢?
      

  18.   


    lIntf := (HTTPRIO1 as IHighWay);
     
      doServiceRes := getIhighWay.doService(doser);改成  doServiceRes := (HTTPRIO1 as IHighWay).doService(doser);
      

  19.   

    没有这样调用函数的getIhighWay( false, 'http://192.168.0.1:8080/LCardService/HighWay?wsdl', nil);
      

  20.   

    在delphi7上问题最后还是没解决,最后升级了2010,问题解决