Transports and Interfaces: Siebel Enterprise Application Integration > EAI DLL and EAI File Transports > About the EAI DLL Transport >

Creating a DLL to Call a Function in an External DLL


The following procedure illustrates how to create a DLL to use the EAI DLL Transport business service to call a function in an external DLL.

As of Siebel Innovation Pack 2014, a new mechanism is provided to free memory allocated. The creator of the external DLL can now expose additional API functions to free memory. Two new business service method arguments, DLLExternalFunction and DLLExternalFunctionFreeMemory, are added to the Send and SendReceive methods. Both arguments are optional input arguments.

  • To use the new mechanism for memory deallocation, you must use both of these arguments together: DLLExternalFunction and DLLExternalFunctionFreeMemory.
  • Customers can optionally use the old approach of only exposing the old argument, ExternalFunction, instead of exposing the new memory freeing API functions. If you continue to use ExternalFunction instead of the new arguments, then the old mechanism is used for memory deallocation. With the old mechanism, failure might occur when the EAI DLL Transport business service performs the memory deallocation.

The signature for the new memory freeing function would resemble the following:

extern "C" int __declspec(dllexport) TestFree(void* Value)

To create a DLL

  1. Open a VC++ project by choosing the Open menu, then New.
  2. Select a Win32 Dynamic Link Library and give a name to the project, such as MyDLL.
  3. In the next dialog box, select the option Simple dll project.

    The following files are created by default:

    • MyDLL.cpp
    • StdAfx.h
    • StdAfx.cpp
  4. Make the following changes in the StdAfx.h and Main.cpp files and check the results in the process simulator:

    // MyDLL.cpp : Defines the exported functions for the DLL application.

    //

    #include "stdafx.h"

    #include <string.h>

    #include <stdio.h>

    #include <io.h>

    #include <malloc.h>

      

    extern "C" int __declspec(dllexport) TestEAI(const XMLDataBuf* pValue, XMLDataBuf* Value)

    {

      FILE *fp = NULL;

      int retf = 0;

      int rc = 0;

      if ((fp = fopen("testeai.txt", "wb")) != NULL)

      {

        fprintf(fp, "Before test");

        fwrite(pValue->pData, sizeof(char), (size_t)pValue->nLength, fp);

        fprintf(fp, " After Test");

        fclose(fp);

      }

      else return -1;

      if ((fp = fopen("testeai.txt", "rb")) != NULL)

      {

        rc = (int)_filelength(_fileno(fp));

        Value->pData = (void *)malloc((size_t)(rc + 1));

        rc = (int)fread(Value->pData, sizeof(char), (size_t)rc, fp);

        fclose(fp);

        Value->nLength = rc;

        ((char*)Value->pData)[rc] = (char)NULL;

      }

      else return -2;

      return rc;

    }

    extern "C" int __declspec(dllexport) TestFree(void* Value)

    {

      if(Value != NULL){

        free (Value);

        Value = NULL;

      }

      

      return 0;

    }

Transports and Interfaces: Siebel Enterprise Application Integration Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Legal Notices.