Welcome to AspAdvice Sign in | Join | Help

.Net Discoveries

An attempt to pass along some answers I have discovered in my .Net coding.
VB.Net and GroupWise Soap Pt. 1 - Getting Logged In

Prologue

One of the things that Microsoft does really well is cater to their developers. If you don't know how to do something, Microsoft is pretty decent about giving you ample sample code to learn it. And if that's not comprehensible (sometimes it's kind of cryptic), then somebody has probably written about it somewhere and it's just a matter of finding that someone's article. I can't say the same about Novell. Now don't get me wrong, I'm not anti-Novell, all our file servers are Novell and our email system is Novell GroupWise, which I really like, but they don't make it easy for their developers like Microsoft does. GroupWise's latest version introduced some web services that you can tap into and use to do all the things that their GW client can do (ok, not quite all yet). But documentation leaves much to be desired and there is VERY little sample code out there to help you figure it out. I had a request from one of our users for creating templates in GroupWise, and figured that I could use the web services to create some templates in the user's draft (work in progress) folder.

I know that I'm possibly limiting the readership of this particular article series, but I figured since the information isn't out there, I'd share what I've found and hopefully it will help someone else like me.

Problem

Figure out how to login and create a draft message in the user's Work in Progress folder that is a template of something the company uses currently in hard copy. In this article, I'm going to look specifically at how to login to the GroupWise system. I plan to do future articles on some of the other information that I find and that I figure out.

Solution

Ok, to get started, create a VB.Net application. I would guess that we could do this almost as easily with ASP.Net, but for the sake of ease (not having to preserve state), let's just use a windows app. On the form, add 4 Labels, 4 TextBoxes, 2 Buttons and a StatusStrip. On the StatusStrip, add a label and name it lblCurrentStatus. The rest of the controls, configure as follows:

Control Type

Name The Control...

and Set Text To...

Label

lblPOAAddress

Post Office Agent Address:

Label

lblPOAPort

Post Office Agent Port:

Label

lblUsername

Username:

Label

lblPassword

Password:

TextBox

txtPOAAddress

 

TextBox

txtPOAPort

TextBox

txtUsername

TextBox

txtPassword

 

Button

btnLogin

Login

Button

btnLogout

Logout

Ok, now we also need to have the Novell GroupWise Services configured on the server, and we'll need to download the Novell Development Kit for GW Soap. We also need to find out the IP address or DNS address for the Post Office Agent (POA), and the port number it listens on (typically 7191). Once you download and install the SDK, you can add a web reference and point it to the WSDL file on your hard drive. Name this Web Reference GWWS.

Ok, now we're ready to get into some code. Open up the code view and let's add two global variables:

Private bLoggedIn As Boolean = False
Private wsGWBinding As GWWS.GroupWiseBinding

We want to track if our application is logged in currently. If it isn't, then we'll have difficulty in future creating messages and other stuff (I tried). We also need to have a GroupWiseBinding object, this inherits the Soap protocols and handles all the back and forth with the server. These will need to remain populated until we release them so we'll create them as globals.

Now lets create a subroutine to log the user in. Create a sub as follow:

Public Sub LoginUser()

End Sub

We need to create some objects to work with as we create our login request. So add the following variables:

Dim req As New GWWS.loginRequest()
Dim resp As GWWS.loginResponse
Dim pText As GWWS.PlainText = New GWWS.PlainText()

First we create a request object, we create it using new so that we can assign values to it. This we pack up with our settings and send to the server using our wsGWBinding object later. Then we create a loginResponse object to receive the response from the server. We also need a plainText authentication object. This allows us to pass username and password to the server in plain text for login. (NOTE: perhaps in a later article I'll do a not plain text one... when I figure it out...)

Now we need to start configuring our objects so that they can be used. So add the following:

wsGWBinding = New GWWS.GroupWiseBinding()
wsGWBinding.Url = "http://" & txtPOAAddress.Text & ":" & txtPOAPort.Text & "/soap"
pText.username = txtUserName.Text
pText.password = txtPassword.Text
req.auth = pText

First we initialize the GroupWiseBinding object so that we can assign stuff to it. Then we start by compiling the url to the web service and adding that to our GroupWiseBinding object. Next, we get the credentials and add them to the plainText object and then assign the plainText object to the request's auth property. Now we've got what we need to try to login, so we'll make the request. Add the following:

resp = wsGWBinding.loginRequest(req)

Here we make the loginRequest and pass in the loginRequest object that contains all our settings. We get back a login response object with the details of what happened. Now we need to parse the response and find out what happened. If login was successful, the response's status.code should be 0, so we'll take some action based on successful login, add the following:

If 0 = resp.status.code Then
   wsGWBinding.session = New GWWS.string() 'initialize session object
   wsGWBinding.session.Text = New String() {resp.session} 'load session obj
   bLoggedIn = True
   lblCurrentStatus.Text = "Logged In..."
End If

First we check to see if current status is logged in, and if so, then we'll store some of the information we go back, and do so me "housekeeping". First we'll store the session's ID, that way we can use it in the future when we want to create a message. We store that in our GroupWiseBinding object and then it'll be passed when we use our GroupWiseBinding object again. This is where stuff get's kind of tricky. We need to create and assign a new string object to the session, then set the session's text property using a string array. The second line creates a new string array and assigns our response object's session to this (since session is a string). Then finally, we note that we are currently logged in, and alert the user that we are logged in. Viola, logged in.

Now for logging out. This is the easier part, we'll create another subroutine for logging out as follows:

Public Sub LogoutUser()

end sub

We also need a variable to receive the logout response:

Dim resp as GWWS.logoutResponse

Now we need to make our actual logout request, so add:

resp = wsGWBinding.logoutRequest(New GWWS.logoutRequest)

This will send our request to the server and we will get a logout response in return. From here, based on success or failure, we'll take some action. Again 0 indicates success so add:

If 0 = resp.status.code Then
   bLoggedIn = False
   wsGWBinding = Nothing
   lblCurrentStatus.Text = "Logged Out"
End If

If logout was successful, we record that we're logged out, alert the user, and then nuke our GroupWiseBinding object so that it holds no current session information. That's it.

Run your app, enter your POA address and port, then put in your username and password. Click login and see it logs in. It should. Then click the Logout and see if it logs out correctly.

Epilogue

Using the web services for GroupWise isn't exactly intuitive, perhaps it is under a different programming model than I'm used to with .Net, but once you figure it out it can be done. Next time we'll look at adding some code to return a folder list from the server after we login.

Sponsor
Posted: Thursday, August 09, 2007 11:22 AM by Yougotiger

Comments

Tim Malloy said:

Thank you for posting this.  It is simple and got me started on using the SOAP API in VB .net.

Tim

# March 10, 2009 11:07 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Enter the code you see below

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS