+ -
当前位置:首页 → 问答吧 → XE2 WebServices变量申请后不能用,D6可以

XE2 WebServices变量申请后不能用,D6可以

时间:2011-12-01

来源:互联网

XE2 WebServices变量申请后不能用,D6可以
报错代码:raised exception class $C0000005 with message 'access violation at 0x004cc1f6: read of address 0x180012f3'.

下面是引入的WDSL单位.
unit GetOrdersService;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;

type

  Materiel = class;  
  Materiel = class(TRemotable)
  private
  Fimage: TByteDynArray;
  FimageName: string;
  FmaterielName: string;
  Fnumber: Double;
  Fprice: Double;
  Fuid: string;
  published
  property image: TByteDynArray read Fimage write Fimage;
  property imageName: string read FimageName write FimageName;
  property materielName: string read FmaterielName write FmaterielName;
  property number: Double read Fnumber write Fnumber;
  property price: Double read Fprice write Fprice;
  property uid: string read Fuid write Fuid;
  end;

  GetOrdersServiceImpl = interface(IInvokable)
  ['{28E2C1A5-4D71-7278-C81B-6B2E93EBD77B}']
  function downloadOrders(const company: string): string; stdcall;
  function uploadMateriels(const materiels: Materiel): Boolean; stdcall;
  end;

function GetGetOrdersServiceImpl(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): GetOrdersServiceImpl;

implementation
  uses SysUtils;

function GetGetOrdersServiceImpl(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): GetOrdersServiceImpl;
const
  defWSDL = 'http://192.168.0.243:8080/saas/services/GetOrdersService?wsdl';
  defURL = 'http://192.168.0.243:8080/saas/services/GetOrdersService';
  defSvc = 'GetOrdersServiceImplService';
  defPrt = 'GetOrdersService';
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 GetOrdersServiceImpl);
  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
  { GetOrdersServiceImpl }
  InvRegistry.RegisterInterface(TypeInfo(GetOrdersServiceImpl), 'http://impl.service.government.com.sasp', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(GetOrdersServiceImpl), '');
  RemClassRegistry.RegisterXSClass(Materiel, 'http://biz.orm.sasp', 'Materiel');

end.

程序,按钮单击事件.

procedure TMainFrm.Button10Click(Sender: TObject);
var
  ss:Materiel;
begin
  ss.uid:='300'; //这里就报错了
  ss.price:=105.33;  
  if (HTTPRIO1 as GetOrdersServiceImpl).uploadMateriels(ss) then
  ShowMessage('Sucess!')
  else
  ShowMessage('False!');
end;

下面是报错代码:
raised exception class $C0000005 with message 'access violation at 0x004cc1f6: read of address 0x180012f3'.

作者: ftwsnow   发布时间: 2011-12-01

已解决,
ss:=Material.create;

作者: ftwsnow   发布时间: 2011-12-02

记得
ss.free

作者: wade520   发布时间: 2011-12-02

我保留记录

作者: tiankun66   发布时间: 2011-12-02

热门下载

更多