3 Replies - 10322 Views - Last Post: 08 March 2013 - 07:40 AM

#1 astian  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 15-June 12

Connecting to WCF service ...

Posted 07 March 2013 - 01:34 AM

So... I am sorry if I have posted the question at the wrong place, yet I couldnt find a better place.
Anyway, my problem is as follows:
A week ago, we had to bring back to life some old projects of the firm. The projects are ... not too complex yet very big, and the real problem is that they are written in DELPHI 6 ... :( . The proccess of rewriting them on C# is soon to begin but we face the pending problem: The projects have to be operational, even only for inner firm operators. SO, an idea was born - to write wcf services for the database related operations of the delphi projects and then create the C# projects over that. So far so good, but here comes the bummer. We can't seem to find a way to consume the WCF from a delphi 6 project.
As my analisys goes so far, from articles in the internet, this is possible. However, I am not entirely sure that is possible on Delphi 6 (usually it is about higher versions of Delphi - 7, CodeGear and so on). As it is said, the best way to verify is to attempt, so ... we tried to connect an empty delphi project to a WCF Service.
About the service:
The service is a simple WCF Service that we actually use in a different project written on Silverlight, and the Silverlight project has no problems consuming the service.
What happens with Delphi:
Following tutorial procedure, we create a new delphi project -> new Project -> other. From the nodes we click 'Web Services' -> web services Importer... . Than in the new window we enter the adress of the service: http://serviceIp:port/Service.svc?wsdl -> button Generate and voala - a Unit file with the Services interfaces is generated. The file looks like this:

Unit Unit2;
interface

uses Types, XSBuiltIns;
type

  IService1 = interface(IInvokable)
    ['{0C53375F-5890-4A30-AD9D-A53304764616}']
    procedure SelectAllImotsByEKATTE(var parameters: SelectAllImotsByEKATTE);  stdcall;
    procedure SelectAllCompOBRbyEKATTE(var parameters: SelectAllCompOBRbyEKATTE);  stdcall;
    procedure SelectAllCompPolzByEKATTE(var parameters: SelectAllCompPolzByEKATTE);  stdcall;
    procedure SelectMinMaxIdOfImotiByEkatte(var parameters: SelectMinMaxIdOfImotiByEkatte);  stdcall;
    procedure comboekatte(var parameters: comboekatte);  stdcall;
    procedure selectAllMestnosti_visual(var parameters: selectAllMestnosti_visual);  stdcall;
    procedure FilMas(var parameters: FilMas);  stdcall;
    procedure SelectMinMaxIdOfImotiByEkatteOchertania(var parameters: SelectMinMaxIdOfImotiByEkatteOchertania);  stdcall;
    procedure selectAllImotsByEkatte_visual(var parameters: selectAllImotsByEkatte_visual);  stdcall;
    procedure selectAllTrainoPolzvane_visual(var parameters: selectAllTrainoPolzvane_visual);  stdcall;
    procedure AllEkatteTa(var parameters: AllEkatteTa);  stdcall;
    procedure AllOblasti(var parameters: AllOblasti);  stdcall;
    procedure NasMqsto(var parameters: NasMqsto);  stdcall;
    procedure Obshtini_vOblast(var parameters: Obshtini_vOblast);  stdcall;
    procedure GradoveSela(var parameters: GradoveSela);  stdcall;
    procedure ekkate_otNasMqsto(var parameters: ekkate_otNasMqsto);  stdcall;
    procedure ValidateLogin(var parameters: ValidateLogin);  stdcall;
    procedure IntersectPoly(var parameters: IntersectPoly);  stdcall;
    procedure SaveIntersections(var parameters: SaveIntersections);  stdcall;
    procedure ProveriBlokaZaPreiz4islqvane(var parameters: ProveriBlokaZaPreiz4islqvane);  stdcall;
    procedure InsertShapesGeometryInDBase(var parameters: InsertShapesGeometryInDBase);  stdcall;
    procedure MergePolygons(var parameters: MergePolygons);  stdcall;
    procedure SaveGeometry(var parameters: SaveGeometry);  stdcall;
    procedure SelectGeometry(var parameters: SelectGeometry);  stdcall;
    procedure SelectGeometryXP(var parameters: SelectGeometryXP);  stdcall;
    procedure SelectGeometryXPofZemlishte(var parameters: SelectGeometryXPofZemlishte);  stdcall;
    procedure UpdateGeometry(var parameters: UpdateGeometry);  stdcall;
    procedure FillGrid(var parameters: FillGrid);  stdcall;
    procedure SelectPointByEkatte(var parameters: SelectPointByEkatte);  stdcall;
    procedure SelectCompByUserId(var parameters: SelectCompByUserId);  stdcall;
    procedure SelectUserIdByUserName(var parameters: SelectUserIdByUserName);  stdcall;
    procedure SelectOblasti(var parameters: SelectOblasti);  stdcall;
    procedure SelectObshtini(var parameters: SelectObshtini);  stdcall;
    procedure SelectZemlByObstID(var parameters: SelectZemlByObstID);  stdcall;
    procedure RegisterCompanyOfUser(var parameters: RegisterCompanyOfUser);  stdcall;
    procedure DeletePolygonByCompAndPole(var parameters: DeletePolygonByCompAndPole);  stdcall;
    procedure SelectIdOfSelectedPolygon(var parameters: SelectIdOfSelectedPolygon);  stdcall;
    procedure EditPole(var parameters: EditPole);  stdcall;
    procedure InsertPole(var parameters: InsertPole);  stdcall;
    procedure FillCultureGrid(var parameters: FillCultureGrid);  stdcall;
    procedure EditCulture(var parameters: EditCulture);  stdcall;
    procedure InsertCulture(var parameters: InsertCulture);  stdcall;
    procedure InsertUpdatePolygonFromShape(var parameters: InsertUpdatePolygonFromShape);  stdcall;
    procedure FillCultureQueryGrid(var parameters: FillCultureQueryGrid);  stdcall;
    procedure FillCultureQueryPoleCombo(var parameters: FillCultureQueryPoleCombo);  stdcall;
    procedure FillCultureQueryCultureCombo(var parameters: FillCultureQueryCultureCombo);  stdcall;
    procedure InsertUpdateCultureQuery(var parameters: InsertUpdateCultureQuery);  stdcall;
    procedure SendMailAboutRegisteredUser(var parameters: SendMailAboutRegisteredUser);  stdcall;
    procedure FillAdministratorGrid(var parameters: FillAdministratorGrid);  stdcall;
    procedure InsertUpdatePolygonFromDigitizer(var parameters: InsertUpdatePolygonFromDigitizer);  stdcall;
  end;


implementation

uses InvokeRegistry;

initialization
  InvRegistry.RegisterInterface(TypeInfo(IService1), '', 'utf-8');

end.



As promising as that looks it doesnt work. When build the compilator returns error - Undeclared identifier FOR ABSOLUTELY every single one of the procedures.
We tried so many things that I cant even remember now, yet we cant get rid of this error (we can change it with a different one but stil ... ).
As I have absolutely no knowledge of Delphi, Pascal or whatever, I dont know if this is something, but I notice that the procedure parameters are not a list of the real parameters of the service method, yet just the name of the procedure itself. Ex - 'procedure SelectAllImotsByEKATTE(var parameters: SelectAllImotsByEKATTE); stdcall;' - is 'public List<string> SelectAllImotsByEKATTE (int number, string byName);' in the service.

Ok, I think I covered as much as I could, if there is anything else that needs to be explained just say so.
I will truly appriciate if someone can help find the answers to these questions:
Is Delphi 6 at particular able to consume WCF Services.
If it does, what are we doing wrong
Any ideas if we can get rid of the Undeclared Identifier...
Is it possible that the problem is in the configuration of the WCF Service.

Any and all help will be really appriciated. Sorry for the long post.

Is This A Good Question/Topic? 0
  • +

Replies To: Connecting to WCF service ...

#2 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2527
  • View blog
  • Posts: 4,629
  • Joined: 24-September 10

Re: Connecting to WCF service ...

Posted 07 March 2013 - 07:47 AM

So I don't write Delphi at all, so I don't have any first hand information for you reguarding delphi exactly.

With out any knowledge I would say, yes, Delphi "should" be able to consume WCF services. Most any framework that can communicate over a net should be able to communicate to a WCF service... may you have to write it from scratch or not, and make sure the WCF service is configured appropriately.

I tried google "delphi 6 consume wcf" and found several articles on the matter. I assume these are the same articles you've already read.



We too have been using WCF for our conversion, but our client is in vb6. To make things easy so we barely had to change any code in vb6, and because we couldn't add any new significant code into vb6. We just wrote a .Net dll to consume the WCF service, and then had vb6 interop with the .Net dll. Maybe you can do that with Delphi?



Have you tried making a super simple WCF service. One with just one method on it that does a stupid simple act. And then tried to consume this super simple service with Delphi 6 the way you describe?

I find it helpful to create little tests like that and get them working, and then scaling them up. Starting with larger stuff can introduce noise making it difficult to debug out what is the problem.
Was This Post Helpful? 1
  • +
  • -

#3 astian  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 25
  • Joined: 15-June 12

Re: Connecting to WCF service ...

Posted 08 March 2013 - 01:03 AM

Well, at first we did exactly that. We created brand new small simple and untouched wcf in VS2010 and started it on the same computer. The template for the WCF project creates two methods, one with custom class and one just returning a string. So, we tried consuming it with Delphi, and it all went exactly as the articles explain... yet the Undeclared Identifier appeared for the first time.
Then, we thought 'hmm, maybe all the configuration we done (which is not much realy) in our usual wcf may be whats missing here' , so we decided to try it with a WCF service that we are certain can be consumed as we consume it with Silverlight Application.
It didnt work both times...
However, as we were desperate we installed Delphi Code Gear on a different computer and tried consuming the WCF service there. And it went smooth. It consumed the wcf service with no problems at all. It generates a incredibly long file (compared to Delphi 6) that doesnt give any errors. We called the method and got our string.
Inspired by the firt results we get in a long time, we got the strangest idea... What would happen if we import the Code Gear generated pas file in Delphi 6.
Probably showing how incompetent we are, or how naive, we actually decided to try it (yes we were that desperate). And when it gave missing files errors, we didnt give up. We copied all required files from the Code Gear into Delphi 6. It was all compiling pritty well, when at the last moment the compilator gave - wrong version of the file error. Its a SOAP service pas file, [which name I dont want to look for], and we are sure to have replaced it with the one from Code gear. So wrong version might be because of that - so we returned the old one. However, the old one works, and the whole thing compiles WITH THE EXCEPTION of a few Registry methods generated in the CodeGear pas file, that turn out to be important. So, that was close, but not close enough.
After this, we were wondering if we cant just migrate our delphi project from delphi 6 to Code gear and we didnt succeed that either. The problem there was that the project is based on a component that was bought 1 milion years ago, and cant be installed on the Code Gear...
Anyway, thank you for the advice, we appriciate the time you spare...
Slowly loosing all hope, we would appriciate if anyone else has any insight on the matter.
Thanks
Was This Post Helpful? 0
  • +
  • -

#4 lordofduct  Icon User is offline

  • I'm a cheeseburger
  • member icon


Reputation: 2527
  • View blog
  • Posts: 4,629
  • Joined: 24-September 10

Re: Connecting to WCF service ...

Posted 08 March 2013 - 07:40 AM

Sounds like every day at my office.

I feel for ya bro.

I wish you luck.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1