Autor Beitrag
bron84
Hält's aus hier
Beiträge: 1



BeitragVerfasst: Mi 10.02.21 09:14 
Hallo zusammen,
ich habe folgendes Problem...rufe einen Webservice auf leider bekomme ich beim Rückgabewert nichts zurück...rufe ich den Webservice via SOAP UI auf bekomme ich ein Ergebnis

Es scheint so als hätte Delphi Probleme mit dem Rückgabewert Row = class(TRemotable)

Mein Aufruf mache ich folgendermaßen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
var
  input:XacuteRequest;
  output:XacuteResponse;
  test: XacuteWSSoap;
  input2:InputParams;
begin
  input2 := InputParams.Create;
  input2.bDebug := true;
  input2.sWorkCenter := 'xx';
  input2.sSite := 'xx';
  input2.sResource := 'xxx';
  input2.iDigits := 14;
  input2.sMaterialNumbers := Edit2.Text;

  input := XacuteRequest.Create;
  output := XacuteResponse.Create;

  //output.Rowset:=Rowset.Create;


  input.InputParams := input2;
  input.LoginName:= 'abc';
  input.LoginPassword:= 'abc';



  test := GetXacuteWSSoap(false, 'https://xxx/getMaterialByTranslatedNumberTransaction');


  output:=test.Xacute(input);



Delphi Code via WSDL Import
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
// ************************************************************************ //
// Die in dieser Datei deklarierten Typen wurden aus Daten der unten
// beschriebenen WSDL-Datei generiert:

// WSDL     : C:\Development\temp\18stellig\Daten.wsdl
//  >Import : C:\Development\temp\18stellig\Daten.wsdl>0
// Codegen  : [wfOutputLiteralTypes+, wfSkipUnusedTypes-, wfUseXSTypeForSimpleNillable+]
// (09.02.2021 14:36:27 - - $Rev: 90173 $)
// ************************************************************************ //

unit Daten4;

interface

uses Soap.InvokeRegistry, Soap.SOAPHTTPClient, System.Types, Soap.XSBuiltIns;

const
  IS_OPTN = $0001;
  IS_UNBD = $0002;
  IS_ATTR = $0010;
  IS_REF  = $0080;


type

  // ************************************************************************ //
  // 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 sie sind in diesem Dokument nicht[!] deklariert. Die Typen aus letzterer Kategorie
  // sind in der Regel vordefinierten/bekannten XML- oder Embarcadero-Typen zugeordnet; sie könnten aber auf 
  // ein inkorrektes WSDL-Dokument hinweisen, das einen Schematyp nicht deklariert oder importiert hat.
  // ************************************************************************ //
  // !:boolean         - "http://www.w3.org/2001/XMLSchema"[!U][GblNlbl]
  // !:long            - "http://www.w3.org/2001/XMLSchema"[!U][GblNlbl]
  // !:string          - "http://www.w3.org/2001/XMLSchema"[!U][GblNlbl]
  // !:boolean         - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:string          - "http://www.w3.org/2001/XMLSchema"[Gbl]
  // !:long            - "http://www.w3.org/2001/XMLSchema"[Gbl]

  Row                  = class;                 { "http://www.sap.com/xMII"[GblCplx] }
  XacuteResponse       = class;                 { "http://www.sap.com/xMII"[Lit][GblElm] }
  Rowset               = class;                 { "http://www.sap.com/xMII"[GblCplx] }
  XacuteRequest        = class;                 { "http://www.sap.com/xMII"[Lit][GblElm] }
  InputParams          = class;                 { "http://www.sap.com/xMII"[GblCplx] }



  // ************************************************************************ //
  // XML       : Row, global, <complexType>
  // Namespace : http://www.sap.com/xMII
  // ************************************************************************ //
  Row = class(TRemotable)
  private
  published
  end;
{    FsMaterialNumbers: string;
    FsMaterialNumbers_Specified: boolean;
    procedure SetsMaterialNumbers(Index: Integer; const Astring: string);
    function  sMaterialNumbers_Specified(Index: Integer): boolean;
  published
    property sMaterialNumbers: string   Index (IS_OPTN) read FsMaterialNumbers write SetsMaterialNumbers stored sMaterialNumbers_Specified;
  end;

  procedure Row.SetsMaterialNumbers(Index: Integer; const Astring: string);
begin
  FsMaterialNumbers := Astring;
  FsMaterialNumbers_Specified := True;
end; }



  Array_Of_Row = array of Row;                  { "http://www.sap.com/xMII"[GblUbnd] }


  // ************************************************************************ //
  // XML       : XacuteResponse, global, <element>
  // Namespace : http://www.sap.com/xMII
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  XacuteResponse = class(TRemotable)
  private
    FRowset: Rowset;
    FRowset_Specified: boolean;
    procedure SetRowset(Index: Integer; const ARowset: Rowset);
    function  Rowset_Specified(Index: Integer): boolean;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property Rowset: Rowset  Index (IS_OPTN) read FRowset write SetRowset stored Rowset_Specified;
  end;



  // ************************************************************************ //
  // XML       : Rowset, global, <complexType>
  // Namespace : http://www.sap.com/xMII
  // ************************************************************************ //
  Rowset = class(TRemotable)
  private
    FMessage_: string;
    FMessage__Specified: boolean;
    FRow: Array_Of_Row;
    FRow_Specified: boolean;
    procedure SetMessage_(Index: Integer; const Astring: string);
    function  Message__Specified(Index: Integer): boolean;
    procedure SetRow(Index: Integer; const AArray_Of_Row: Array_Of_Row);
    function  Row_Specified(Index: Integer): boolean;
  public
    destructor Destroy; override;
  published
    property Message_: string        Index (IS_ATTR or IS_OPTN) read FMessage_ write SetMessage_ stored Message__Specified;
    property Row:      Array_Of_Row  Index (IS_OPTN or IS_UNBD) read FRow write SetRow stored Row_Specified;
  end;



  // ************************************************************************ //
  // XML       : XacuteRequest, global, <element>
  // Namespace : http://www.sap.com/xMII
  // Serializtn: [xoLiteralParam]
  // Info      : Wrapper
  // ************************************************************************ //
  XacuteRequest = class(TRemotable)
  private
    FLoginName: string;
    FLoginName_Specified: boolean;
    FLoginPassword: string;
    FLoginPassword_Specified: boolean;
    FInputParams: InputParams;
    FInputParams_Specified: boolean;
    procedure SetLoginName(Index: Integer; const Astring: string);
    function  LoginName_Specified(Index: Integer): boolean;
    procedure SetLoginPassword(Index: Integer; const Astring: string);
    function  LoginPassword_Specified(Index: Integer): boolean;
    procedure SetInputParams(Index: Integer; const AInputParams: InputParams);
    function  InputParams_Specified(Index: Integer): boolean;
  public
    constructor Create; override;
    destructor Destroy; override;
  published
    property LoginName:     string       Index (IS_OPTN) read FLoginName write SetLoginName stored LoginName_Specified;
    property LoginPassword: string       Index (IS_OPTN) read FLoginPassword write SetLoginPassword stored LoginPassword_Specified;
    property InputParams:   InputParams  Index (IS_OPTN) read FInputParams write SetInputParams stored InputParams_Specified;
  end;



  // ************************************************************************ //
  // XML       : InputParams, global, <complexType>
  // Namespace : http://www.sap.com/xMII
  // ************************************************************************ //
  InputParams = class(TRemotable)
  private
    FbDebug: Boolean;
    FbDebug_Specified: boolean;
    FiDigits: Int64;
    FiDigits_Specified: boolean;
    FsMaterialNumbers: string;
    FsMaterialNumbers_Specified: boolean;
    FsResource: string;
    FsResource_Specified: boolean;
    FsSite: string;
    FsSite_Specified: boolean;
    FsWorkCenter: string;
    FsWorkCenter_Specified: boolean;
    procedure SetbDebug(Index: Integer; const ABoolean: Boolean);
    function  bDebug_Specified(Index: Integer): boolean;
    procedure SetiDigits(Index: Integer; const AInt64: Int64);
    function  iDigits_Specified(Index: Integer): boolean;
    procedure SetsMaterialNumbers(Index: Integer; const Astring: string);
    function  sMaterialNumbers_Specified(Index: Integer): boolean;
    procedure SetsResource(Index: Integer; const Astring: string);
    function  sResource_Specified(Index: Integer): boolean;
    procedure SetsSite(Index: Integer; const Astring: string);
    function  sSite_Specified(Index: Integer): boolean;
    procedure SetsWorkCenter(Index: Integer; const Astring: string);
    function  sWorkCenter_Specified(Index: Integer): boolean;
  published
    property bDebug:           Boolean  Index (IS_OPTN) read FbDebug write SetbDebug stored bDebug_Specified;
    property iDigits:          Int64    Index (IS_OPTN) read FiDigits write SetiDigits stored iDigits_Specified;
    property sMaterialNumbers: string   Index (IS_OPTN) read FsMaterialNumbers write SetsMaterialNumbers stored sMaterialNumbers_Specified;
    property sResource:        string   Index (IS_OPTN) read FsResource write SetsResource stored sResource_Specified;
    property sSite:            string   Index (IS_OPTN) read FsSite write SetsSite stored sSite_Specified;
    property sWorkCenter:      string   Index (IS_OPTN) read FsWorkCenter write SetsWorkCenter stored sWorkCenter_Specified;
  end;


  // ************************************************************************ //
  // Namespace : http://www.sap.com/xMII
  // soapAction: http://www.sap.com/xMII
  // Transport : http://schemas.xmlsoap.org/soap/http
  // Stil     : document
  // Verwenden von       : literal
  // Bindung   : XacuteWSSoap
  // Service   : XacuteWS
  // Port      : XacuteWSSoap
  // URL       : https://sapeiq.blanc-fischer.com:51001/XMII/SOAPRunner/G_MII_INTERFACE/CoreFunctions/Material/getMaterialByTranslatedNumberTransaction
  // ************************************************************************ //
  XacuteWSSoap = interface(IInvokable)
  ['{918641B2-4942-255C-305D-E7206E249D09}']

    // Entpacken nicht möglich: 
    //     - Name des Eingabeelement-Wrappers entspricht nicht dem Operationsnamen
    function  Xacute(const parameters: XacuteRequest): XacuteResponse; stdcall;
  end;

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


implementation
  uses System.SysUtils;

function GetXacuteWSSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): XacuteWSSoap;
const
  defWSDL = 'C:\Development\temp\18stellig\Daten.wsdl';
  defURL  = 'https://sapeiq.blanc-fischer.com:51001/XMII/SOAPRunner/G_MII_INTERFACE/CoreFunctions/Material/getMaterialByTranslatedNumberTransaction';
  defSvc  = 'XacuteWS';
  defPrt  = 'XacuteWSSoap';
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 XacuteWSSoap);
    if UseWSDL then
    begin
      RIO.WSDLLocation := Addr;
      RIO.Service := defSvc;
      RIO.Port := defPrt;
    end else
      RIO.URL := Addr;
  finally
    if (Result = niland (HTTPRIO = nilthen
      RIO.Free;
  end;
end;


constructor XacuteResponse.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

destructor XacuteResponse.Destroy;
begin
  System.SysUtils.FreeAndNil(FRowset);
  inherited Destroy;
end;

procedure XacuteResponse.SetRowset(Index: Integer; const ARowset: Rowset);
begin
  FRowset := ARowset;
  FRowset_Specified := True;
end;

function XacuteResponse.Rowset_Specified(Index: Integer): boolean;
begin
  Result := FRowset_Specified;
end;

destructor Rowset.Destroy;
var
  I: Integer;
begin
  for I := 0 to System.Length(FRow)-1 do
    System.SysUtils.FreeAndNil(FRow[I]);
  System.SetLength(FRow, 0);
  inherited Destroy;
end;

procedure Rowset.SetMessage_(Index: Integer; const Astring: string);
begin
  FMessage_ := Astring;
  FMessage__Specified := True;
end;

function Rowset.Message__Specified(Index: Integer): boolean;
begin
  Result := FMessage__Specified;
end;

procedure Rowset.SetRow(Index: Integer; const AArray_Of_Row: Array_Of_Row);
begin
  FRow := AArray_Of_Row;
  FRow_Specified := True;
end;

function Rowset.Row_Specified(Index: Integer): boolean;
begin
  Result := FRow_Specified;
end;

constructor XacuteRequest.Create;
begin
  inherited Create;
  FSerializationOptions := [xoLiteralParam];
end;

destructor XacuteRequest.Destroy;
begin
  System.SysUtils.FreeAndNil(FInputParams);
  inherited Destroy;
end;

procedure XacuteRequest.SetLoginName(Index: Integer; const Astring: string);
begin
  FLoginName := Astring;
  FLoginName_Specified := True;
end;

function XacuteRequest.LoginName_Specified(Index: Integer): boolean;
begin
  Result := FLoginName_Specified;
end;

procedure XacuteRequest.SetLoginPassword(Index: Integer; const Astring: string);
begin
  FLoginPassword := Astring;
  FLoginPassword_Specified := True;
end;

function XacuteRequest.LoginPassword_Specified(Index: Integer): boolean;
begin
  Result := FLoginPassword_Specified;
end;

procedure XacuteRequest.SetInputParams(Index: Integer; const AInputParams: InputParams);
begin
  FInputParams := AInputParams;
  FInputParams_Specified := True;
end;

function XacuteRequest.InputParams_Specified(Index: Integer): boolean;
begin
  Result := FInputParams_Specified;
end;

procedure InputParams.SetbDebug(Index: Integer; const ABoolean: Boolean);
begin
  FbDebug := ABoolean;
  FbDebug_Specified := True;
end;

function InputParams.bDebug_Specified(Index: Integer): boolean;
begin
  Result := FbDebug_Specified;
end;

procedure InputParams.SetiDigits(Index: Integer; const AInt64: Int64);
begin
  FiDigits := AInt64;
  FiDigits_Specified := True;
end;

function InputParams.iDigits_Specified(Index: Integer): boolean;
begin
  Result := FiDigits_Specified;
end;

procedure InputParams.SetsMaterialNumbers(Index: Integer; const Astring: string);
begin
  FsMaterialNumbers := Astring;
  FsMaterialNumbers_Specified := True;
end;

function InputParams.sMaterialNumbers_Specified(Index: Integer): boolean;
begin
  Result := FsMaterialNumbers_Specified;
end;

procedure InputParams.SetsResource(Index: Integer; const Astring: string);
begin
  FsResource := Astring;
  FsResource_Specified := True;
end;

function InputParams.sResource_Specified(Index: Integer): boolean;
begin
  Result := FsResource_Specified;
end;

procedure InputParams.SetsSite(Index: Integer; const Astring: string);
begin
  FsSite := Astring;
  FsSite_Specified := True;
end;

function InputParams.sSite_Specified(Index: Integer): boolean;
begin
  Result := FsSite_Specified;
end;

procedure InputParams.SetsWorkCenter(Index: Integer; const Astring: string);
begin
  FsWorkCenter := Astring;
  FsWorkCenter_Specified := True;
end;

function InputParams.sWorkCenter_Specified(Index: Integer): boolean;
begin
  Result := FsWorkCenter_Specified;
end;

initialization
  { XacuteWSSoap }
  InvRegistry.RegisterInterface(TypeInfo(XacuteWSSoap), 'http://www.sap.com/xMII''');
  InvRegistry.RegisterDefaultSOAPAction(TypeInfo(XacuteWSSoap), 'http://www.sap.com/xMII');
  InvRegistry.RegisterInvokeOptions(TypeInfo(XacuteWSSoap), ioDocument);
  InvRegistry.RegisterInvokeOptions(TypeInfo(XacuteWSSoap), ioLiteral);
  RemClassRegistry.RegisterXSClass(Row, 'http://www.sap.com/xMII''Row');
  RemClassRegistry.RegisterXSInfo(TypeInfo(Array_Of_Row), 'http://www.sap.com/xMII''Array_Of_Row');
  RemClassRegistry.RegisterXSClass(XacuteResponse, 'http://www.sap.com/xMII''XacuteResponse');
  RemClassRegistry.RegisterSerializeOptions(XacuteResponse, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(Rowset, 'http://www.sap.com/xMII''Rowset');
  RemClassRegistry.RegisterExternalPropName(TypeInfo(Rowset), 'Message_''[ExtName="Message"]');
  RemClassRegistry.RegisterXSClass(XacuteRequest, 'http://www.sap.com/xMII''XacuteRequest');
  RemClassRegistry.RegisterSerializeOptions(XacuteRequest, [xoLiteralParam]);
  RemClassRegistry.RegisterXSClass(InputParams, 'http://www.sap.com/xMII''InputParams');

end.


Hier die Ausgabe von SOAP UI
ausblenden XML-Daten
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <XacuteResponse xmlns="http://www.sap.com/xMII">
         <Rowset>
            <Row>
               <sMaterialNumber>1234</sMaterialNumber>
               <sTranslatedNumber>12345</sTranslatedNumber>
            </Row>
         </Rowset>
      </XacuteResponse>
   </soap:Body>
</soap:Envelope>



Habe den Typ Row = class(TXMLData) mal geändert leider bringt das auch nicht
Hat jemand einen Tipp was ich noch machen kann?
Einloggen, um Attachments anzusehen!
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19272
Erhaltene Danke: 1740

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 10.02.21 10:42 
Ich verwende für solche Fälle gern ein einfaches PHP Skript, das mir alle Parameter sowie den Request-Body in Textdateien auf meinem Server schreibt (mit alphabetisch sortierten Headern usw. für bessere Vergleiche mit z.B. BeyondCompare). Dann kann ich in einem funktionierenden Test und in meiner eigenen Anwendung die URL auf dieses Ziel setzen und den Request direkt vergleichen.

Natürlich gibt es auch Tools dafür, die das auf dem Weg abfangen usw., aber ich finde diesen Weg erst einmal schneller für einen kurzen Vergleich, weil man dafür nur die URL anpassen muss.

Der zweite Punkt betrifft die Delphiversion:
Hier wäre es sinnvoll es einmal mit der neuesten Version zu testen, da ich mit älteren Versionen schon mehrfach Probleme hatten, die mit der aktuellen schlicht schon gelöst waren.