XML Interop in 8.98

Gary P

Active Member
Hello all,

I'm tasked with learning and implementing XML interoperability in our JDE environment. Based on the examples I've seen, you have a program, called an invoker, that reads the XML file, connects to JDE, and processes the file. I have the examples from Oracle to use a C/C++ invoker, but I'm having trouble getting it to compile, mainly because it is missing a library xmlinterop.h. I can't find this file on my FAT client, or any of the enterprise servers we use. However, my company just completed a project with a third party company that uses XML (I'm trying to get them to tell us what they did), so I'm beginning to think the how-to guides I'm using are outdated.

For those who are able to get XML interop working on 8.98 or later, how did you do it? Was there an invoker that you used, and how did that work? If possible, I would prefer to use C/C++ in visual studio 2008, but am willing to use whatever will work.

Thanks,
Gary Pollock
 
Hi Gary,

Yes, it's true the header file is no longer delivered with a fat client, yet the jdeXMLRequest API is still exported in xmlinterop.dll. In C/C++ you can perform dynamic linking with LoadLibrary and GetProcAddress to resolve a function pointer and call the API.

Let me know if you need more info.

Craig
 
Thanks for your help. For anyone else reading this, the correct GetProcAddress to use is "_jdeXMLRequest@20".

However, now I'm getting a new problem: every time it runs it returns error code 13:jdeXMLRequest parameter invalid. I've found that I get the same error code whether I change the server, the port, the user ID, so I'm unable to figure out what exactly I'm doing wrong. I'll keep trying.
 
Are you passing Unicode strings? Also the size parameter is the size in bytes not characters.
 
I got it working. You are correct that I had to use unicode strings. Maybe I could have used JDE conversion functions, but I found more documentation for the windows ones, so that's what I used. Here's what I had to do, as well as an overview:

First, my variables:
<font class="small">Code:</font><hr /><pre>
char *buf;
DWORD dwSize;
DWORD dwBytesRead;
HANDLE hFile;
char* presp;

wchar_t wideHost[30];
unsigned short * host;
unsigned short port;
int timeout;
size_t *convSuc = 0;

HINSTANCE hinstLib;
XMLREQ ProcXML;
JDEFREEXMLRESPONSE FreeResp;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
</pre><hr />

Here's what it took to load the libraries and functions:
In header
<font class="small">Code:</font><hr /><pre>
typedef char* (__stdcall *XMLREQ)(unsigned short const *,unsigned short,int, void *, int);
typedef void* (__stdcall *JDEFREEXMLRESPONSE)(void*);
</pre><hr />

In code:
<font class="small">Code:</font><hr /><pre>
hinstLib = LoadLibrary(TEXT("xmlinterop.dll"));
ProcXML = (XMLREQ) GetProcAddress(hinstLib, "_jdeXMLRequest@20");
FreeResp = (JDEFREEXMLRESPONSE) GetProcAddress(hinstLib, "_jdeFreeXMLResponse@4");
</pre><hr />

Loading and reading the input XML file:
<font class="small">Code:</font><hr /><pre>
if(INVALID_HANDLE_VALUE == (hFile = CreateFile(CA2T(argv[1]), GENERIC_READ,
0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)))

buf = new char[dwSize + 1];
memset( buf, 0, dwSize+1 );
if(!ReadFile(hFile, buf, dwSize, &dwBytesRead, NULL))</pre><hr />

And finally converting to unicode and calling the API:
<font class="small">Code:</font><hr /><pre>
mbstowcs_s(convSuc, wideHost, strlen(argv[2]) + 1, argv[2], _TRUNCATE);
host = (unsigned short *)(wideHost);
port = atoi(argv[3]);
presp = (ProcXML)(host, port, atoi(argv[4]), buf, 0);
</pre><hr />

The rest should be easy to figure out just by searching for the Oracle examples.

Thanks for the help you've been, Craig. The next steps for me are to improve this app to provide better logging and tracing, learn more about calling this, and use this to help our business run smoother. If anyone has any further questions on what I found out, I'll be happy to do what I can.
 
No prob, glad it's working. One important thing to note is that you do not need a full E1 fat/developer client for this solution to work, but you do need the following DLLs from ...\system\bin32:

icudt32.dll
icui18n.dll
icuuc.dll
jdel.dll
jdeunicode.dll
PSThread.dll
ustdio.dll
xmlinterop.dll
 
Back
Top