up vote 11 down vote favorite
This is my first post on this forum and I hope that I am able to ask my question in the correct way. Sorry for the length, but I found it hard to cut it down.
I am using Delphi XE2 to communicate with a fairly large SOAP service. I've successfully imported the wsdl and everything is working just fine. However, I find myself writing a lot of similar code. I would like to have a generic method that calls my web service. I also find it hard to multithread my code as it is now, since I have to write so much code for each type of call.
Being more of a weekend programmer I am far from mastering the in and outs of Delphi, but I think I at least have a fair understanding of RTTI, which I believe must be used to do what I want.
The web service has about 700 different methods and that is pretty much the problem. The code generated from the wsdl has methods as below:
Basically, there is about 700 different type of things that can be handled, and there is add,update,get,remove and list-methods for them all. With each call, there is a corresponding class that is used as parameters to the SOAP request. There is also a corresponding class for the response as you can see above.
The classes would look something like (very simplified):
So when I call the web service I do for example:
(Yes, I know I should have try..finally and Free in there as well :-) )
Then, somewhere else in the code I need to call a different method:
Since I know that the parameter is always a class with a name that is equivalent of the method I call, I would like to be able to do something like the metacode below in order to dynamically invoking the call. I guess it requires some RTTI magic but I have'nt been able to find a way to do it:
Then I could do something like:
Does anyone have an idea how my calls to the webservice can be simplified?
Thanks in advance
Dan
delphi soap delphi-xe2 rtti
share|improve this question
edited Jun 28 at 16:28
TLama
20.3k32572
asked Jun 28 at 15:11
dahook
916
It will be interesting to see if anyone comes up with such, but I just wrote wrapper routines like you have to "hide" the details. – mj2008 Jun 28 at 15:28
3@dahook: Very nicely written first post. Voted up. Welcome to SO. – Robert Frank Jun 28 at 15:29
feedback