cancel
Showing results for 
Search instead for 
Did you mean: 

I want to use a VposCOMAPI.dll, written by vs2010, from PB9 or later.

Former Member
0 Kudos

I want to use a VposCOMAPI.dll, written by vs2010,  from PB9 or later.

I use the following code:

OLEObject obj

int ret_code, ret_Code2

obj = create OLEObject

String Auth_code, Rsp_code,  Rsp_msg

ret_code = obj.ConnectToNewObject("VposCOMAPI.dll")

if ret_code <> 0 then

   destroy obj

   messagebox("error", "Error !" + string(ret_code))

   return

else

   obj.apiInit()

   obj.CARD_NO="9999111188882222"

   obj.MERCHANTID = "0909090909"

   obj.executeAuth()

   ret_Code2 = obj.AUTH_RETCODE

   if ret_Code2 = 0 then

       Auth_code = obj.APPROVE_CODE

       Rsp_code = obj.RESPONSE_CODE

       Rsp_msg = obj.RESPONSE_MSG

       messagebox("OK", "OK !")

   else

       messagebox("error2", "Error2 !")

   end if

   destroy obj

end if

I got the ret_code “ Errorcode  -2 ( Class name not found )”.

Anybody could help me ?

Could I use the VposCOMAPI.dll in this way ?

Thanks !

Jack

PS : The VposCOMAPI.dll works in VS2010

1 Add Reference --> Browse

2 VB sample code

Public Class Form1

Dim ac As New VposCOMAPI.ApiClient

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim retCode As Integer

rspCode.Text = ""

rspMsg.Text = ""

approveCode.Text = ""

txnNo.Text = ""

txnDate.Text = ""

apiResult.Text = ""

ac.setPORT(443)

ac.setLogFile("D:\workTemp\vposApi.log")

ac.setURL("nccnet-vpostest.nccc.com.tw", "/vposMert/servlets/apiControl")

ac.setMERCHANT_ID(merchantId.Text)

ac.setTERMINAL_ID(posId.Text)

ac.setEXPIRE_DATE(expireDate.Text)

ac.setCARD_NO(cardNo.Text)

3 C# sample code

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.Diagnostics;

using System.IO;

using VposCOMAPI;

namespace testCSapi

{

public partial class Form1 : Form

{

public Form1() {InitializeComponent();}

private void send_Click(object sender, EventArgs e)

{

int retCode = 0;

ApiClient ac = new VposCOMAPI.ApiClient();

ac.setURL("nccnet-vpostest.nccc.com.tw", "/vposMert/servlets/apiControl");

ac.setLOGFILE("D:/workTemp/vpos/log/testCSapi.log");

ac.setMERCHANT_ID(merchantId.Text);

ac.setTERMINAL_ID(posId.Text);

ac.setEXPIRE_DATE(expireDate.Text);

ac.setCARD_NO(cardNo.Text);

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Jack,

From the code VB sample, I would say it should be:

ret_code = obj.ConnectToNewObject("VposCOMAPI.ApiClient")

You should be able to see it in the PowerBuilder browser on the OLE tab.

I don't know this dll or under which name it is listed (VposCOMAPI or Microsoft VposCOMAPI or something else) but if you expand the Programmable and\or Insertable Objects then after been registered it should be in the list and you should see it's progID to use.

Ben

Former Member
0 Kudos

Hi Ben,

The question point is:

         the VposCOMAPI.dll, written by vs2010, is .net COM+ object for .Net Framework 2.0/3.0/3.5/4.0 platform;

         the VposAPI.dll, written in VB6, is ActiveX/Com object for windows environment;


         How to call VposCOMAPI.dll's method in PB9 ?

         Could we use  OLEObject ,  ConnectToNewObject. ... powerscripts ?

         and How to call VposAPI.dll's method in PB9 ?


Thanks !

Jack

Former Member
0 Kudos

Hi,

A few things to remember. They must be 32-bit ComVisible or COM Interop registered assemblies.

You need to use the ProgId to connect to; have you checked if they were visible in the browser?

As Jacob mentions,

These have been discussed before by Bruce, particularly in the PowerBuilder Deveopment Center and in other places.

A few more references:


http://scn.sap.com/message/14156871#14156871
http://scn.sap.com/community/developer-center/powerbuilder/blog/2013/02/28/using-net-assemblies-with...
http://scn.sap.com/community/developer-center/powerbuilder/blog/2014/07/19/calling-net-assemblies-fr...
http://pbdj.sys-con.com/node/397016
http://pbdj.sys-con.com/node/258395

Ben

Former Member
0 Kudos

Hi Ben & Jacob,

Thanks !  Follow your directions.

I can use .NET assembly (VposCOMAPI.dll) with PowerBuilder 9 after done GacUtil & RegAsm.

The next question is:

How to deploy to the end users' PCs  ?

Each PC needs to install .NET Framework  and  be done GAUtil & RegAsm ?

Last question is : The VposAPI.dll  is still not workable in PB9 ! Have any suggestion ?

1. VposCOMAPI.dll, written by vs2010, is .net COM+ object for .Net Framework 2.0/3.0/3.5/4.0 platform;

2.  VposAPI.dll, written in VB6, is ActiveX/Com object for windows environment;

Jack

Former Member
0 Kudos

If the second dll is just a wrapper for the first one, then you may not need it.

You will need to describe more detailed what exactly doesn't work with the VposAPI.dll.

Doesn't it show up in the browser or what actually happens or what errors do you get?

Deployment would be a separate issue.

I think you could best ask that in a separate discusion and provide all necessary details.

But also in a different group the

It has a much larger group of readers for such questions then this SAP PowerBuilder group.

Ben

Answers (1)

Answers (1)

CobyKako
Advisor
Advisor
0 Kudos

Hello Jack,

The problem in your PowerScript is here: ret_code = obj.ConnectToNewObject("VposCOMAPI.dll")

The argument for the method is not a DLL but a CLSID. That way you could connect to your OLE server.

HTH

Jacob

Former Member
0 Kudos

Hi Jacob,

I have finished "regsvr32 VposAPI.dll" and got the CLSID from "regedit".

ret_code = obj.ConnectToNewObject("9FDC2104-F3B2-4FD3-AEB7-99944DEBEB6E")


I got same error code ( -2 ).


Other supplementary:

1. VposAPI.dll is  ActiveX/Com object for windows environment;

2.VposCOMAPI.dll is Com+ object for .Net Framework 2.0/3.0/3.5/4.0 platform;


What is right way  to use  VposAPI.dll or  VposCOMAPI.dll in PB9 or later.


Thanks !

 

Jack