Login / Logoff using COM

jpsst34

Well Known Member
Using JDE COM objects with VB. I'm using the JDECOMCONNECTOR2Lib, using the following methods to login and logout of JDE:

JDECOMCONNECTOR2Lib.Connector.Login
JDECOMCONNECTOR2Lib.Connector.Logoff

When I call the login function, I'm connected to JDE and a JDE icon appears in my system tray. I can right click this and choose close, and the connection is closed. The icon goes away and calls to the JDE bsfn's from within my app fail. If, however, I call the logoff function from within my VB app, the icon does not go away. I am no longer connected, as calls to bsfn's from within the VB fail, but I must still manually right click the system tray icon and choose "Close."Anyone know why this is? How can I completely disconnect from JDE from within my VB app after opening a connection, and have that system try icon go away?

Thanks,
 
Hi,

Please let me know if you find anything on this issue.

Are you having any problems because of the icon in the system tray? I have the same situation, but the connection is definitely closed, and the icon doesn't seem to cause any harm. (at least not that I am aware of!) Of course a reboot always cleans it up.

Thanks, Jenifer

OneWorld XE, SP 18.1, AS/400 820 V5R1
 
Right now I'm developing the first VB-to-JDE app for our shop. I'm the only one using it right now, but I can see a problem when this thing hits the user's desks if they logout but the system tray is telling them otherwise. After my app has closed and the logoff method has been called, the system tray icon remains, and you can still right click it and choose "Close." But there's no close method in the COM object.

It's not a showstopper issue, but if there's no way to get rid of the icon from within the VB app, it's more than a minor inconvenience.
 
Hi Friends,

We do have the same situation. We are not facing any problem with that though. One interested thing we noticed was when we use multi threaded program with different connections open still JDE is not creating different connection objects. So by looking at that situation I think JDE is wantedly doing that for giving the ability to design multi-threaded applications (I am not sure). But in our client site we haven’t put any efforts to close that tray icon. I think we can close that tray icon by suing external Vb API called “Shell_NotifyIcon”

Ex retValue=Shell_NotifyIcon(NIM_DELETE, hndOneWorld)

I haven’t tried this one yet.
 
First an FYI, then a question:

FYI to anyone who may want to do this:
To use the Shell_NotifyIcon API call, you must first declare the function, as well as the NOTIFYICONDATA structure and the available constants for the message parameter:

Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean

Private Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uId As Long
uFlags As Long
uCallBackMessage As Long
hIcon As Long
szTip As String * 64
End Type

Const NIM_ADD = &H0
Const NIM_MODIFY = &H1
Const NIM_DELETE = &H2
Const NIF_MESSAGE = &H1
Const NIF_ICON = &H2
Const NIF_TIP = &H4
Const WM_MOUSEMOVE = &H200
Const WM_LBUTTONDOWN = &H201 'Button down
Const WM_LBUTTONUP = &H202 'Button up
Const WM_LBUTTONDBLCLK = &H203 'Double-click
Const WM_RBUTTONDOWN = &H204 'Button down
Const WM_RBUTTONUP = &H205 'Button up
Const WM_RBUTTONDBLCLK = &H206 'Double-click

It can then be used by first filling in the values of a NOTIFYICONDATA type variable, then setting some boolean variable = to the function call:

Dim iconRetVal As Boolean
Dim nid As NOTIFYICONDATA

With nid
.cbSize = Len(nid)
.hwnd = Me.hwnd
.uId = vbNull
'Add Icon, Tooltip and Callback Message
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.uCallBackMessage = WM_MOUSEMOVE
.hIcon = ' set this to the handle of the OW icon
.szTip = "Messenger 5.0" & vbNullChar
End With
iconRetVal = Shell_NotifyIcon(NIM_DELETE, nid)



Now my question:

How do you get the handle to the OW icon? That is what do I set nid.hIcon equal to?
 
Looking into closing another app's icon, I got the following response when asking a colleague if it's possible: "I don't think there's a way to kill some other app's icon (apart from using something like Spy++ to guess at the hWnd and then sending random identifiers until you happen upon the correct one), but doing that would probably cause problems in the app that is displaying it."


Realistically, JDE should provide a means to close this icon through a method in the Connector interface. I have logged the following issue with JDE through the Knowledge Garden. I will keep the list posted to the status of this issue.

-------------------------------------------------------------------
Connector System Tray Icon left behind after disconnect

Interoperability (COM) - I use the JDECOMConnector2 library to access JDE through a COM link from a custom VB app. When I call the Connector.Login method, an icon is added to the system tray upon successful connection. When I call the Connector.Logoff method, the connection is successfully closed, but the system tray icon is left behind. It seems that the only way to get rid of the icon is to manually right-click it and choose close. This is disconcerting, as it leaves the user to wonder, "Is the connection closed? Is it safe to close this?" Ideally, for consistency, this icon should be deleted upon successful logoff, since it is added upon successful login. However, if this can't be acheived, a method for deleting the icon through the Connector class should be provided.
 
Thanks Jack for keeping up updated.

I've not done the VB to JDE route yet - but I plan to and your information provided here will be valuable to me then.

Thanks again!
 
I thought if you open a connection in the following way you would get connection handle into hOWCn. If you use .Login method I am also not sure how can we get the handle.

Private OWCn As New JDECOMCONNECTOR2Lib.Connector
Dim OWIntfc As JDECOMCONNECTOR2Lib.OneWorldInterface
Set OWIntfc = OWCn.CreateBusinessObject("OneWorld.FunctionHelper.1", hOWCn)
 
I am currently experiencing a similar problem; however I have a different spin. We are accessing a custom business function through the Comconnector using VB. We have an application in distribution where multiple users can add contracts, however we do not want them to login each time. We incorporated using the same login id each time and then updating the userid column after the standard JDE function is called. It works great until we get more then 10 users using the application at the same time. We believe using the same login is causing the processes to step on one another. The error we get is when we try and connect to the business function:
JDETest = JDEConnector.CreateBusinessObject("JDETest.PO", lngSessionID)

The error returned is: "The object is incompatible with the logon environment"

Has anyone come across this error? Does the JDECommconnector only allow a user one concurrent thread at a time per business function?

Once this happens if we switch to another login the application will work. We are logging off after each call.

ANy thoughts would be appreciated.
Thanks
 
If you call "Set OWIntfc = OWCn.CreateBusinessObject("OneWorld.FunctionHelper.1", hOWCn) " before logging into oneworld, it throws an error: "You have not logged into oneworld."

In order for this code to work, you need to log in first, and use the Long value returned from the login method (the session ID) as the second parameter to the CreateBusinessObject method:



Private OWCn As New JDECOMCONNECTOR2Lib.Connector
Dim OWIntfc As JDECOMCONNECTOR2Lib.OneWorldInterface

hOWCn = OWCn.Login(username, password, environment)

Set OWIntfc = OWCn.CreateBusinessObject("OneWorld.FunctionHelper.1", hOWCn)
 
I logged an issue with JDE describing this behavior. The end result is that JDE answered basically "This is how it works. I'll enter an enhancement SAR." Going on experience, this means they'll return it as "Redesign not planned" and that will be the end of it. The conversation follows:

JDE:
"I have tested this and I have the same thing happen. There is not a way to close out the icon currently other than manually closing it. If you would like to pursue this further an enhancement SAR can be entered for this issue. Let me know if this is the route you would like to pursue."

Jack:
"Thanks for looking into this for me. The icon is associated with the connector process that shows up in the task manager as JDECOM~1.EXE. I see that if I leave this process running and then re-run my VB app, it uses the same connector even though in my code I create a new instance of Connector. It doesn't create another instance of JDECOM~1.EXE. That's a good thing.

Please enter an enhancement SAR to add a method to the Connector interface allowing the user some means of closing JDECOM~1.EXE from within the user's application."

JDE:
"I will enter that SAR. Thanks and have a good day!"
 
Jack,

I have been following this thread and have been interested in it's outcome. It seems to me that your verbage on your request, specifically: "...means of closing JDECOM~1.EXE from within the user's application." leaves the door open for JDE to say works as designed.

By this I mean, the connector is really just a 'bridge' from a pc to JDE. Only one instance will run on a given pc at any given time. Multiple apps may use this 'bridge' at the same time so not allowing an app to close that 'bridge' is good (thus the works as designed). It seems to me that JDE should change the .logoff method to determine if any apps are currently using the 'bridge' and, if not, close it.

Just my two cents....
 
I recieved an auto-generated email from JDE this morning stating that the status of this SAR, Number 6303766, has changed. Not unexpectedly, it has changed to a status of 4 - Returned - Redesign not Planned.
 
Olive,

Did you resolve this. I'm seeing something similiar and believe it may be related to the security history functionality (F9312) which we had switched on

For the moment I'm testing with the secuity history turned off

/ Ian
 
Hi all, i am facing a problem with the logging into JDE using com.It keeps prompting me "Exception error" when i try to login and where should i start to solve this??

Code goes like this:

Dim OW as JDECOMCONNECTOR2Lib.OneWorldInterface
Dim conn as JDECOMCONNECTOR2Lib.Connector
Dim connRole as JDECOMCONNECTOR2Lib.IConnector2
Dim Login as Long

try
Login = connRole.Login("Userid","PW","Environment","Role")
catch ex As Exception
msgbox(ex.message)
end try

That simple and i face a "Exception error when i step into the Login = connRole.Login("Userid","PW","Environment","Role") step.

Please help help! Thanks !!

Using VB.net2003 to interface with JDE.
 
Here's some sample code from a vb.net web service we wrote using the COM
interoperability. I'm a novice at .net development and had someone with
more experience help me get this working, so I probably can't answer any
questions about this code. Hopefully an example will be enough to point
you in the right direction.



Ellen Deak

Senior Systems Developer

Cooper Standard Automotive

JDE EnterpriseOne (OneWorld XE Update 7 SP23_M1), AS400 DB2 V5R3M0,
Citrix Clients

VB.NET 2003, BizTalk 2004







Imports System.Web.Services

Imports JDE_N0100041Lib ' This is the DLL generated by the
gencom command

Imports JDE_AddressBookMBF



<System.Web.Services.WebService(Namespace:=3D"http://tempuri.com/JDE_Addr e

Public Class JDE_AddressBookMBF

Inherits System.Web.Services.WebService



Private WithEvents _owInterface As
JDECOMCONNECTOR2Lib.OneWorldInterface

Private _errors As New System.Text.StringBuilder

Private _warnings As New System.Text.StringBuilder



<WebMethod(EnableSession:=3DTrue)> _

Public Function InvokeJDEAddressBookMBF(ByVal parms As
AddressBookMBFParameters) As AddressBookMBFParameters

If (IsNothing(parms)) Then Throw New
Protocols.SoapException("The parameter 'Parms' cannot be null.",
Protocols.SoapException.ClientFaultCode,
Context.Request.Url.AbsoluteUri)



Dim completed As Boolean =3D False

Dim connection As New JDECOMCONNECTOR2Lib.Connector

Dim handle As Long

Dim parameterSet As JDE_N0100041Lib.D0100041

Dim addressBook As JDE_N0100041Lib.AddressBookMBF



Try

handle =3D connection.Login(GetUserID, GetUserPassword,
GetAppEnvironment)

_owInterface =3D New JDECOMCONNECTOR2Lib.OneWorldInterface

_owInterface =3D
connection.CreateBusinessObject("OneWorld.FunctionHelper.1", handle)

addressBook =3D
connection.CreateBusinessObject("JDE_N0100041.AddressBookMBF", handle)

parameterSet =3D
addressBook.CreateAddressBookMasterMBFParameterset()



If ((IsNothing(_owInterface)) OrElse
(IsNothing(addressBook)) OrElse (IsNothing(parameterSet))) Then

_errors.Append("One of the required objects failed to
create. Check error messages.")

Else

MapParametersToJDE(parameterSet, parms)

addressBook.AddressBookMasterMBF(parameterSet,
_owInterface, connection, handle)

MapJDEToParameters(parameterSet, parms)

completed =3D True

End If

Catch ex As Exception

If (ex.Message.ToLower <> "unspecified error") Then

_errors.Append(ex.Message)

End If

Finally

If (Not IsNothing(connection)) Then

connection.Logoff(handle)

End If

End Try

If (_errors.Length > 0) Then parms.errorList =3D _errors.ToString

If (_warnings.Length > 0) Then parms.warningList =3D
_warnings.ToString

parms.completed =3D completed

Return parms

End Function
 
Re: RE: Login / Logoff using COM

Hi eydeak,

Thanks, gotta try it out when i m back in office.
 
Re: RE: Login / Logoff using COM

Eydeak,

Nope, its not working...well well.. headache..
 
Back
Top