Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29231 Discussions

Call a .Net WCF service dll in Fortran?

Roanna_L_
Beginner
865 Views

I have an application in Fortran needs to connect to .Net WCF service, which is written in VS C++. The WCF service allows client to connect to it and access the functions defined inside it. I have a smple of Wcfclient written in C++ to show how to access WCF service.The WCF service should allow both Fortran and C++ client to access.

However, how do I call functions defined in WCF service since .Net WCF doesn't allow to use traditional C++ libraray attributes, such as "extern C.."

The source code of .Net WCF service and sample of C++ client code are attached.

0 Kudos
2 Replies
onkelhotte
New Contributor II
865 Views

Hi Roanna,

I haven´t examined your code because I don´t have much time today...

Here is what I did when I added CORBA functionality to my fortran code. I wrote a C++ lib that received the CORBA calls from a WPF GUI and this lib called the proper fortran routines. Then I linked this lib into my fortran project. Here is an example:

[cpp]
extern "C" void SAVEPROJECT(const char*, CORBA::Long*);
void DataExchange_i::saveDFCProjectFile(const char* filename)
{
CORBA::Long lenFilename = sizeof(filename);
SAVEPROJECT(filename, &lenFilename);
}[/cpp]

[fortran]
subroutine saveProject(filename)
!DEC$ ATTRIBUTES DLLEXPORT :: saveProject
!DEC$ ATTRIBUTES ALIAS: '_SAVEPROJECT' :: saveProject
! some code
end subroutine saveProject
[/fortran]

From my WPF GUI I call saveDFCProjectFile and this calls saveProject in my fortran code. Maybe you could do something like this with WCF too.

Markus

0 Kudos
Roanna_L_
Beginner
865 Views

Hi Markus,

This is a very good idea. Insteading of making Fortran to call WCF, I could make a C++ program to call both Fortran and WCF to exchange data. I am going to give a try.

Thanks.

Roanna

0 Kudos
Reply