Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi Win32 Receiving a datatable from ASP.NET service

Tags:

soap

delphi

I'm building a Delphi Win32 app that should consume a Soap Service, which turns out to be a .NET based app. One function returns a DataTable. Of course, Delphi Win32 (not Delphi .NET) has no way of understanding this natively.

Any way I can make it work? I'll be happy to parse the XML manually too, but I've no idea how to get hold of the raw XML response.

The WSDL: https://stratus.voxamvia.co.za/api.asmx?WSDL

The function: GetNotifications which returns GetNotificationsResult, which builds as:

  GetNotificationsResult = class(TRemotable)
  private
    Fnamespace: WideString;
    Fnamespace_Specified: boolean;
    FtableTypeName: WideString;
    FtableTypeName_Specified: boolean;
    procedure Setnamespace(Index: Integer; const AWideString: WideString);
    function  namespace_Specified(Index: Integer): boolean;
    procedure SettableTypeName(Index: Integer; const AWideString: WideString);
    function  tableTypeName_Specified(Index: Integer): boolean;
  published
    property namespace:     WideString  Index (IS_ATTR or IS_OPTN) read Fnamespace write Setnamespace stored namespace_Specified;
    property tableTypeName: WideString  Index (IS_ATTR or IS_OPTN) read FtableTypeName write SettableTypeName stored tableTypeName_Specified;
  end;

Any help appreciated!

Would it help if I implement RemObjects?

like image 222
Hein du Plessis Avatar asked Nov 04 '11 07:11

Hein du Plessis


2 Answers

You can build your dataset from xml. This should give you a starting point: http://www.gekko-software.nl/DotNet/Art07.htm and http://www.gekko-software.nl/DotNet/Art08.htm.

I haven't used DataAbstract from RemObjects, so I can not give an advice on it.

LE: you can access and consume a web service written in .net by following this simple article well written by drbob - Consuming C# Web Services with Delphi 7 Professional

which contains also a small example on how to build dynamically and how to use the THttpRio (is the same as the Mikael Eriksson's answer)

like image 122
RBA Avatar answered Oct 10 '22 15:10

RBA


Any way I can make it work? I'll be happy to parse the XML manually too, but I've no idea how to get hold of the raw XML response.

You can get it in the OnAfterExecuteEvent on your THTTPRIO component. There you will have SOAPResponse: TStream as a parameter.

Update:

To get the event to fire you add a THTTPRIO component, create the event handler and use the RIO component as the third parameter to GetAPISoap.

This worked for me. HTTPRIO1 is a component on the form.

procedure TForm7.Button1Click(Sender: TObject);
var
  A: APISoap;
begin
  A := GetAPISoap(False, '', HTTPRIO1);
  A.Validate_User('', '');
end;
like image 42
Mikael Eriksson Avatar answered Oct 10 '22 17:10

Mikael Eriksson