Article

From:
To:
Yoran Van Hoecke
Subject:
Re: Delphi - SAP SOAP WebService no return values
Newsgroup:
embarcadero.public.delphi.webservices

Re: Delphi - SAP SOAP WebService no return values

Hello,

>
> I have a webservice from SAP, it has one operation "ZMymcsCustomersMulti"
>
> <wsdl:operation name="ZMymcsCustomersMulti">
> <wsp:Policy>
> <wsp:PolicyReference URI="#OP_ZMymcsCustomersMulti"/>
> </wsp:Policy>
> <wsdl:input message="tns:ZMymcsCustomersMulti"/>
> <wsdl:output message="tns:ZMymcsCustomersMultiResponse"/>
> </wsdl:operation>
>
> As you can see the return value should be of the type 
> "ZMymcsCustomersMultiResponse".
> After I imported this service into my delphi project the operation doesn't 
> have any return values.
>
> As you can see in the delphi generated code the webservice doesn't return 
> any values, but the wsdl file clearly states it should return a value of 
> the type "ZMymcsCustomersMultiResponse".
>
> How can I change the delphi generated code to solve this issue?
> I have already tried creating the type myself and registering the class in 
> the webservice but the function still doesn't return any values.
>
> Please help me solve this issue...
>


The service matches the rule for wrapped convention for document|literal 
services (see 
http://atmanes.blogspot.com/2005/03/wrapped-documentliteral-convention.html). 
When that happens, by default, the WSDL importer will unwrap. If you don't 
want it to unwrap you must turn OFF that feature. If you run "WSDLImp.exe" 
without any parameters you'll see the list of options:

{code} Embarcadero WSDLIMP Version 2.41 - $Rev: 44408 $ Copyright (c) 2010 Embarcadero Technologies, Inc.
Usage: WSDLIMP [options] <WSDL[File|URL]>
 Language Generation Options:   -C Generate C++ code   -P Generate Pascal code
 Code Generation Options [ -option{+|-} default shown ]:   -Oa+ Process nillable and optional elements   -Ob- Use Setters and Getters for properties   -Od+ Generate destructors for remotable types   -Oe+ Generate scoped enumerations   -Of+ Import Fault Types   -Og- Generate interface GUIDs using COM API   -Oh+ Import Header Types   -Oi+ Generate warning comments   -Oj+ Validate Enumeration members   -Ok- Map pure collections to wrapper class types   -Ol- Emit wrapper element Types   -Om- Allow out parameters   -Oo+ One out parameter is return value   -Op+ Process included and imported schemas   -Or- Generate alias for the element of pure collections   -Os- Generate server implementation instead of client proxies   -Ot+ Do not emit unused types   -Ou+ Unwrap wrapper elements (wrapped doc|lit services)   -Ov+ Generate verbose information about types and interfaces   -Ow- Map String to WideString   -Ox+ Generate class aliases as class types   -Oz- Use TXSxxxx classes for simple nillable types
 SOAP Version Options:   Automatically determines SOAP version if not forced. (Recommended)   -SOAP11 Process only WSDL Binding extensions for the SOAP 1.1 Protocol   -SOAP12 Process only WSDL Binding extensions for the SOAP 1.2 Protocol
 File options:   -D<path> Output directory path   -=+ Output filename after '=' in URL   @<Resp> Response file with list of WSDL
 Proxy/Server Authentication:   -user:userName -pass:Password [-proxy:Proxy] {code}
The one option you want to use is this one:
{code}   -Ou+ Unwrap wrapper elements (wrapped doc|lit services) {code}
Unwrapping is ON by default. To turn it off use "-Ou-", as in:
{code}   wsdlimp -ou- service.wsdl {code}
The importer will then generate this code instead:
{code} // ************************************************************************ // // The types declared in this file were generated from data read from the // WSDL File described below: // WSDL : service.wsdl // >Import : service.wsdl>0 // Encoding : utf-8 // Codegen : [wfUnwindLiteralParameters-] // Version : 1.0 // (12/13/2011 11:36:28 AM - - $Rev: 44408 $) // ************************************************************************ //
unit service;
interface
uses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;
const   IS_OPTN = $0001;   IS_UNBD = $0002;   IS_UNQL = $0008;   IS_REF = $0080;

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 Embarcadero 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"[Gbl]
  ZmcsCustomer = class; { "urn:sap-com:document:sap:soap:functions:mc-style"[GblCplx] }   ZMymcsCustomersMultiResponse = class; { "urn:sap-com:document:sap:soap:functions:mc-style"[GblElm] }   ZMymcsCustomersMulti = class; { "urn:sap-com:document:sap:soap:functions:mc-style"[GblElm] }


  // ************************************************************************ //   // XML : ZmcsCustomer, global, <complexType>   // Namespace : urn:sap-com:document:sap:soap:functions:mc-style   // ************************************************************************ //   ZmcsCustomer = class(TRemotable)   private     FName_: string;     FStreet: string;     FPostcode: string;     FCity: string;     FMessage_: string;   published     property Name_: string Index (IS_UNQL) read FName_ write FName_;     property Street: string Index (IS_UNQL) read FStreet write FStreet;     property Postcode: string Index (IS_UNQL) read FPostcode write FPostcode;     property City: string Index (IS_UNQL) read FCity write FCity;     property Message_: string Index (IS_UNQL) read FMessage_ write FMessage_;   end;
  StringTable = array of string; { "urn:sap-com:document:sap:soap:functions:mc-style"[GblCplx] }   ZmcsCustomerInfoT = array of ZmcsCustomer; { "urn:sap-com:document:sap:soap:functions:mc-style"[GblCplx] }

  // ************************************************************************ //   // XML : ZMymcsCustomersMultiResponse, global, <element>   // Namespace : urn:sap-com:document:sap:soap:functions:mc-style   // ************************************************************************ //   ZMymcsCustomersMultiResponse = class(TRemotable)   private     FReturn: ZmcsCustomerInfoT;     FTcustomers: StringTable;   public     destructor Destroy; override;   published     property Return: ZmcsCustomerInfoT Index (IS_UNQL) read FReturn write FReturn;     property Tcustomers: StringTable Index (IS_UNQL) read FTcustomers write FTcustomers;   end;


  // ************************************************************************ //   // XML : ZMymcsCustomersMulti, global, <element>   // Namespace : urn:sap-com:document:sap:soap:functions:mc-style   // ************************************************************************ //   ZMymcsCustomersMulti = class(TRemotable)   private     FCustomer: string;     FCustomer_Specified: boolean;     FReturn: ZmcsCustomerInfoT;     FReturn_Specified: boolean;     FTcustomers: StringTable;     FTcustomers_Specified: boolean;     procedure SetCustomer(Index: Integer; const Astring: string);     function Customer_Specified(Index: Integer): boolean;     procedure SetReturn(Index: Integer; const AZmcsCustomerInfoT: ZmcsCustomerInfoT);     function Return_Specified(Index: Integer): boolean;     procedure SetTcustomers(Index: Integer; const AStringTable: StringTable);     function Tcustomers_Specified(Index: Integer): boolean;   public     destructor Destroy; override;   published     property Customer: string Index (IS_OPTN or IS_UNQL) read FCustomer write SetCustomer stored Customer_Specified;     property Return: ZmcsCustomerInfoT Index (IS_OPTN or IS_UNQL) read FReturn write SetReturn stored Return_Specified;     property Tcustomers: StringTable Index (IS_OPTN or IS_UNQL) read FTcustomers write SetTcustomers stored Tcustomers_Specified;   end;

  // ************************************************************************ //   // Namespace : urn:sap-com:document:sap:soap:functions:mc-style   // transport : http://schemas.xmlsoap.org/soap/http   // style : document   // use : literal   // binding : ZMCS_CUSTOMER_MULTI   // service : ZMCS_CUSTOMER_MULTI   // port : ZMCS_CUSTOMER_MULTI   // URL : http://localhost/zmcs_customer_multi   // ************************************************************************ //   z_mcs_customers_multi = interface(IInvokable)   ['{DDFC4969-7467-E4D1-D6A2-37D3C09C4750}']     function ZMymcsCustomersMulti(const parameters: ZMymcsCustomersMulti): ZMymcsCustomersMultiResponse; stdcall;   end;
function Getz_mcs_customers_multi(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): z_mcs_customers_multi;

implementation   uses SysUtils;
function Getz_mcs_customers_multi(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): z_mcs_customers_multi; const   defWSDL = 'service.wsdl';   defURL = 'http://localhost/zmcs_customer_multi';   defSvc = 'ZMCS_CUSTOMER_MULTI';   defPrt = 'ZMCS_CUSTOMER_MULTI'; 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 z_mcs_customers_multi);     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;

destructor ZMymcsCustomersMultiResponse.Destroy; var   I: Integer; begin   for I := 0 to System.Length(FReturn)-1 do     SysUtils.FreeAndNil(FReturn[I]);   System.SetLength(FReturn, 0);   inherited Destroy; end;
destructor ZMymcsCustomersMulti.Destroy; var   I: Integer; begin   for I := 0 to System.Length(FReturn)-1 do     SysUtils.FreeAndNil(FReturn[I]);   System.SetLength(FReturn, 0);   inherited Destroy; end;
procedure ZMymcsCustomersMulti.SetCustomer(Index: Integer; const Astring: string); begin   FCustomer := Astring;   FCustomer_Specified := True; end;
function ZMymcsCustomersMulti.Customer_Specified(Index: Integer): boolean; begin   Result := FCustomer_Specified; end;
procedure ZMymcsCustomersMulti.SetReturn(Index: Integer; const AZmcsCustomerInfoT: ZmcsCustomerInfoT); begin   FReturn := AZmcsCustomerInfoT;   FReturn_Specified := True; end;
function ZMymcsCustomersMulti.Return_Specified(Index: Integer): boolean; begin   Result := FReturn_Specified; end;
procedure ZMymcsCustomersMulti.SetTcustomers(Index: Integer; const AStringTable: StringTable); begin   FTcustomers := AStringTable;   FTcustomers_Specified := True; end;
function ZMymcsCustomersMulti.Tcustomers_Specified(Index: Integer): boolean; begin   Result := FTcustomers_Specified; end;
initialization   { z_mcs_customers_multi }   InvRegistry.RegisterInterface(TypeInfo(z_mcs_customers_multi), 'urn:sap-com:document:sap:soap:functions:mc-style', 'utf-8');   InvRegistry.RegisterDefaultSOAPAction(TypeInfo(z_mcs_customers_multi), '');   InvRegistry.RegisterInvokeOptions(TypeInfo(z_mcs_customers_multi), ioDocument);   InvRegistry.RegisterInvokeOptions(TypeInfo(z_mcs_customers_multi), ioLiteral);   RemClassRegistry.RegisterXSClass(ZmcsCustomer, 'urn:sap-com:document:sap:soap:functions:mc-style', 'ZmcsCustomer');   RemClassRegistry.RegisterExternalPropName(TypeInfo(ZmcsCustomer), 'Name_', '[ExtName="Name"]');   RemClassRegistry.RegisterExternalPropName(TypeInfo(ZmcsCustomer), 'Message_', '[ExtName="Message"]');   RemClassRegistry.RegisterXSInfo(TypeInfo(StringTable), 'urn:sap-com:document:sap:soap:functions:mc-style', 'StringTable');   RemClassRegistry.RegisterXSInfo(TypeInfo(ZmcsCustomerInfoT), 'urn:sap-com:document:sap:soap:functions:mc-style', 'ZmcsCustomerInfoT');   RemClassRegistry.RegisterXSClass(ZMymcsCustomersMultiResponse, 'urn:sap-com:document:sap:soap:functions:mc-style', 'ZMymcsCustomersMultiResponse');
RemClassRegistry.RegisterExternalPropName(TypeInfo(ZMymcsCustomersMultiResponse),
'Return', '[ArrayItemName="item"]');
RemClassRegistry.RegisterExternalPropName(TypeInfo(ZMymcsCustomersMultiResponse),
'Tcustomers', '[ArrayItemName="item"]');
  RemClassRegistry.RegisterXSClass(ZMymcsCustomersMulti, 
'urn:sap-com:document:sap:soap:functions:mc-style', 'ZMymcsCustomersMulti');
  RemClassRegistry.RegisterExternalPropName(TypeInfo(ZMymcsCustomersMulti), 
'Return', '[ArrayItemName="item"]');
  RemClassRegistry.RegisterExternalPropName(TypeInfo(ZMymcsCustomersMulti), 
'Tcustomers', '[ArrayItemName="item"]');

end. {code}
Let me know if the above does not help.
Cheers,
Bruneau
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Thu, 28 Mar 2024 19:13:07 UTC
Copyright © 2009-2024
HREF Tools Corp.