Thema: Delphi Webservice

Einzelnen Beitrag anzeigen

InschenierSB

Registriert seit: 25. Apr 2018
Ort: Regensburg
39 Beiträge
 
#1

Webservice

  Alt 25. Apr 2018, 14:59
Servus,
ich bin neu hier und habe erst vor kurzem mit Delphi 6 begonnen.
Jetzt habe ich die Aufgabe einen Webservice zu erstellen. Die dazugehörige WSDL Datei habe ich vom Kunden bekommen. Über SOAP UI habe ich die WSDL schon eingebunden, da bekomme ich eine Antwort mit
der entsprechenden Anfrage.
Allerdings bekomme ich im Delphi bei Ausführung ständig die FM: Object reference not set to an instance of an object!
Wer hat eine Idee woran das liegen könnt?

Wer das löst bekommt was von mir, ohne Witz!!

Viele Grüße
Sebastian

Delphi-Code in der Main.pas:

Delphi-Quellcode:
  private
    { Private-Deklarationen }


  public
    { Public-Deklarationen }

  end;

   var
  Form1: TForm1;
  sResult:ILot;
  Response:String;



implementation

{$R *.dfm}


    var
    ToolCode:string;
    CheckSlotPos:boolean;
    EquipmentValidation:boolean;
    LotName:string;
    ReturnBrokenWafers:boolean;
     UseSlotPosition:boolean;

procedure TForm1.Button1Click(Sender: TObject);

begin
  // HTTPRIO1 := THTTPRIO.Create(nil);
 // ToolCode:='1ELAM3';
 // CheckSlotPos:= false;
 // EquipmentValidation:=false;
  // LotName:='R173419P';
   //ReturnBrokenWafers:=true;
   //UseSlotPosition:=false;
   //HTTPRIO1.WSDLLocation:= 'C:\SebastianBihn\Lot\Test\Lot.xml';
  HTTPRIO1.URL := 'http://tst-rbg14:8019/Lot.svc';
  HTTPRIO1.Service := 'Lot';
  HTTPRIO1.Port := 'BasicHttpBinding_ILot';

 //HTTPRIO1.URL:='http://tst-rbg14:8019/Lot.svc';
 //sResult:=
// sResult:=(HTTPRIO1 as ILot);
 (HTTPRIO1 as ILot).GetLotInfoByLotName(ToolCode,CheckSlotPos,EquipmentValidation,LotName,ReturnBrokenWafers,UseSlotPosition);
 //SBHTTPRIO1 := THTTPRIO.Create(nil);
 //Memo1.Lines.Text:= sResult;
end;

end.
Delphi-Code der WSDL:

Code:
// ************************************************************************ //
// Die in dieser Datei deklarierten Typen wurden aus Daten generiert, die aus
// unten beschriebener WSDL-Datei stammen:
// WSDL    : C:\SebastianBihn\Lot\Test\Lot.xml
//  >Importieren : http://tst-rbg14:8019/Lot.svc?wsdl=wsdl0
// Codieren : utf-8
// Version : 1.0
// (25.04.2018 09:21:01 - $Revision:  1.9.1.0.1.0.1.9  $)
// ************************************************************************ //

unit Lot;

interface

uses InvokeRegistry, Types, XSBuiltIns;

type
    ToolCode=string;
     CheckSlotPos=boolean;
    EquipmentValidation=boolean;
    LotName=string;
    ReturnBrokenWafers=boolean;
     UseSlotPosition=boolean;
    GetLotInfoByLotNameResponse =string;
  // ************************************************************************ //
  // Die folgenden Typen, auf die im WSDL-Dokument Bezug genommen wird, sind in dieser Datei
  // nicht repräsentiert. Sie sind entweder Aliase(@) anderer repräsentierter Typen oder auf sie wurde Bezug genommen,
  // aber in diesem Dokument nicht deklariert (!). Die Typen aus letzterer Kategorie
  // sind normalerweise mit vordefinierten/bekannten XML- oder Borland-Typen verbunden; sie könnten aber auch ein Anzeichen
  // für ein falsches WSDL-Dokument sein, das einen Schema-Typ nicht deklariert oder importiert..
  // ************************************************************************ //
  // !:GetLotInfoByLotName - "http://cim.osram.ws.gefasoft.com/"
  // !:GetLotInfoByLotNameResponse - "http://cim.osram.ws.gefasoft.com/"
  // !:GetLotByName   - "http://cim.osram.ws.gefasoft.com/"
  // !:GetLotByNameResponse - "http://cim.osram.ws.gefasoft.com/"
  // !:HoldLot        - "http://cim.osram.ws.gefasoft.com/"
  // !:HoldLotResponse - "http://cim.osram.ws.gefasoft.com/"
  // !:SplitLotByGravure - "http://cim.osram.ws.gefasoft.com/"
  // !:SplitLotByGravureResponse - "http://cim.osram.ws.gefasoft.com/"
  // !:SplitLotByGravureWorkflow - "http://cim.osram.ws.gefasoft.com/"
  // !:SplitLotByGravureWorkflowResponse - "http://cim.osram.ws.gefasoft.com/"
  // !:SplitLotByNameWorkflow - "http://cim.osram.ws.gefasoft.com/"
  // !:SplitLotByNameWorkflowResponse - "http://cim.osram.ws.gefasoft.com/"
  // !:ComposeLot     - "http://cim.osram.ws.gefasoft.com/"
  // !:ComposeLotResponse - "http://cim.osram.ws.gefasoft.com/"
  // !:GetGroupByLot  - "http://cim.osram.ws.gefasoft.com/"
  // !:GetGroupByLotResponse - "http://cim.osram.ws.gefasoft.com/"
  // !:MergeLot       - "http://cim.osram.ws.gefasoft.com/"
  // !:MergeLotResponse - "http://cim.osram.ws.gefasoft.com/"
  // !:AssignLotToEquipmentPort - "http://cim.osram.ws.gefasoft.com/"
  // !:AssignLotToEquipmentPortResponse - "http://cim.osram.ws.gefasoft.com/"


  // ************************************************************************ //
  // Namespace : http://cim.osram.ws.gefasoft.com/
  // binding  : BasicHttpBinding_ILot
  // Service  : Lot
  // Port     : BasicHttpBinding_ILot
  // URL      : http://tst-rbg14:8019/Lot.svc
  // ************************************************************************ //
  ILot = interface(IInvokable)
  ['{1E7F22BE-D470-57BE-AF25-CBAC66BA2E10}']
    function GetLotInfoByLotName(ToolCode:string;CheckSlotPos:boolean;EquipmentValidation:boolean;LotName:string;ReturnBrokenWafers:boolean;
      UseSlotPosition:boolean): GetLotInfoByLotNameResponse; stdcall;
   // function GetLotInfoByLotName(ToolCode, CheckSlotPos): GetLotInfoByLotNameResponse; stdcall;
  //  function GetLotByName(const parameters: GetLotByName): GetLotByNameResponse; stdcall;
  //  function HoldLot(const parameters: HoldLot): HoldLotResponse; stdcall;
  //  function SplitLotByGravure(const parameters: SplitLotByGravure): SplitLotByGravureResponse; stdcall;
  //  function SplitLotByGravureWorkflow(const parameters: SplitLotByGravureWorkflow): SplitLotByGravureWorkflowResponse; stdcall;
  //  function SplitLotByNameWorkflow(const parameters: SplitLotByNameWorkflow): SplitLotByNameWorkflowResponse; stdcall;
  //  function ComposeLot(const parameters: ComposeLot): ComposeLotResponse; stdcall;
  //  function GetGroupByLot(const parameters: GetGroupByLot): GetGroupByLotResponse; stdcall;
   // function MergeLot(const parameters: MergeLot): MergeLotResponse; stdcall;
  // function AssignLotToEquipmentPort(const parameters: AssignLotToEquipmentPort): AssignLotToEquipmentPortResponse; stdcall;
  end;

function GetILot(UseWSDL: Boolean=System.false; Addr: string=''): ILot;


implementation
  uses SOAPHTTPClient;

  function GetILot(UseWSDL: Boolean; Addr: string): ILot;


const
  defWSDL = 'C:\SebastianBihn\Lot\Test\Lot.xml';
  defURL = 'http://tst-rbg14:8019/Lot.svc';
  defSvc = 'Lot';
  defPrt = 'BasicHttpBinding_ILot';
var
  HTTPRIO1: THTTPRIO;
begin
  Result := nil;
  if (Addr = '') then
  begin
    if UseWSDL then
      Addr := defWSDL
    else
      Addr := defURL;
  end;
  HTTPRIO1 := THTTPRIO.Create(nil);
  try
     if UseWSDL then
    begin
      HTTPRIO1.WSDLLocation := Addr;
      HTTPRIO1.Service := defSvc;
      HTTPRIO1.Port := defPrt;
    end else
      HTTPRIO1.URL := Addr;
   Result := (HTTPRIO1 as ILot);
  finally
    if Result = nil then
      HTTPRIO1.Free;
  end;


end;


initialization
  InvRegistry.RegisterInterface(TypeInfo(ILot), 'http://cim.osram.ws.gefasoft.com/', 'UTF-8');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ILot), 'http://cim.osram.ws.gefasoft.com/ILot/GetLotInfoByLotName');
 // InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ILot), '');
   InvRegistry.RegisterInvokeOptions(TypeInfo(ILot), ioDocument);
end.
  Mit Zitat antworten Zitat