IPBX_Marshaler interface

Description

The IPBX_Marshaler interface is used to invoke remote methods and convert PowerBuilder data formats to the user’s communication protocol. A marshaler extension is a PowerBuilder extension that acts as the bridge between PowerBuilder and other components, such as EJBs, Java classes, CORBA objects, Web services, and so on.

Methods

Table 7-5: IPBX_Marshaler methods

Method

Description

Destroy

Destroys an instance of an object inherited from the IPBX_Marshaler structure

GetModuleHandle

Returns the handle of the PBX that contains the native class

InvokeRemoteMethod

Used in PowerBuilder marshaler native classes to call remote methods




Destroy

Description

Use the Destroy method to destroy instances of objects inherited from the IPBX_Marshaler structure.

Syntax

Destroy( )

Returns

None.

Examples

Example 1

This code destroys the current instance of the SampleMarshaler structure:

void SampleMarshaler::Destroy()
{
  delete this;
}

Usage

You must implement this method in the marshaler native class after creating an instance of a marshaler structure and invoking remote methods.

See also




GetModuleHandle

Description

Returns the handle of the PBX that contains the native class. This method is required to allow the PowerBuilder VM to determine which PBXs can be unloaded.

Syntax

GetModuleHandle( )

Returns

pbulong

Examples

Example 1

This code in the implementation of a marshaler class returns the handle of the PBX:

extern pbulong thisModuleHandle;
pbulong SampleMarshaler::GetModuleHandle()
{
   return thisModuleHandle;
}

The handle is set in the main module:

pbulong thisModuleHandle = 0;

BOOL APIENTRY DllMain( HANDLE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                )
{
   thisModuleHandle = (pbulong)hModule;

    switch (ul_reason_for_call)
   {
      case DLL_PROCESS_ATTACH:
      case DLL_THREAD_ATTACH:
      case DLL_THREAD_DETACH:
      case DLL_PROCESS_DETACH:
         break;
    }
    return TRUE;
}

Usage

You must implement this method in the marshaler native class.

See also




InvokeRemoteMethod

Description

Used in PowerBuilder marshaler native classes to call remote methods.

Syntax

InvokeRemoteMethod(IPB_Session *session, pbproxyobject obj, LPCTSTR methodDesc, PBCallInfo *ci)

Argument

Description

session

This IPB session

obj

The proxy object for the remote object

methodDesc

An arbitrary string stored as an alias name for the remote method in the proxy, for example: function int foo(int a) alias "This is a method in remote BizTalk"

ci

The parameters and return value setting for the call

Returns

PBXRESULT.PBX_OK if the call succeeded.

Examples

Example 1

This example shows a header file for a sample marshaler class:

#include "sampleinclude.h"
#include <pbext.h>

class SampleMarshaler : public IPBX_Marshaler
{
private:
   string   d_mystring;
   long     d_mylong;

private:
   void myMethod(string arg1);

public:
   SampleMarshaler(
      string myString,
      long   mylong
      );
   ~SampleMarshaler();

   virtual PBXRESULT InvokeRemoteMethod
      (
      IPB_Session*   session,
      pbproxyObject  obj,
      LPCTSTR        methodDesc,
      PBCallInfo*    ci
      );


   virtual pbulong   GetModuleHandle();
   virtual void Destroy();};

The associated C++ implementation file contains code like this:

PBXRESULT SampleMarshaler::InvokeRemoteMethod
(
   IPB_Session*   session,
   pbproxyObject  obj,
   LPCTSTR        methodDesc,
   PBCallInfo*    ci
)
{
   // method invocation
}

Usage

You must implement this method in the marshaler native class.

See also