Value of type... cannot be converted to...

mancroft

New member
Joined
May 29, 2005
Messages
1
Location
Lost
Programming Experience
3-5
Value of type... cannot be converted to...

Hello

I am trying to log in to a web services site using Express 2005 Beta 2 and display some details returned by the return header (sessionHdr).

The (slightly cut-down) code below gives the error:

VB.NET:
 Value of type 'logintest.com.lansdowne.services.bfHeader' cannot be converted to 'logintest.com.lansdowne.services.LoginSoap'.

at the line where it says

VB.NET:
  SessionHdr = oLogin.bfHeaderValue

Any help is much appreciated.


VB.NET:
  Imports logintest.com.lansdowne.services
  Imports System
  
  Public Class fmMain
  	Inherits System.Windows.Forms.Form
  
  #Region "Global variables"
  
  	'Set up public variables
	Public oLogin As LoginSoap		 'Initialise SOAP port global variable
	Public bfh As bfHeader			 'Initialise SOAP header for Login use
  	Public SessionHdr As LoginSoap	   'Initialise Session header
  
  	Public loggedIn As Boolean		   'Initialise boolean
  
  	Private Sub Form_Load()
  
  		oLogin = New LoginSoap
  		bfh = New bfHeader
  		SessionHdr = New LoginSoap
  
  		loggedIn = False
  
  	End Sub
  
  #End Region
  
  #Region "Login"
  	' Login button
  	Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
  				Handles btnLogin.Click
  		' Set flag for whether logged in or not
  		loggedIn = False
  		' Hide the login message control
  		lblNotLoggedIn.Hide()
  		' Detect if login details entered, if not send message 
  		'Details test goes here
  	End Sub
  
  	Public Sub doLogin()
  		'Set SOAP header
  
  		oLogin.bfHeaderValue = bfh
  
  		'Login
  		Try
			' oLogin calls the service port and passes header values,
  			' ServiceLogin is the calling procedure
  		
  			oLogin.ServiceLogin()
  		
  		Catch ooops As Exception
			' If there's problem with logging in, call fail procedure
  			loginMessage()
  		End Try
  
  		' UPON LOGIN SUCCESS...
  		' Keep the global header variable for this project 
  		'up to date
  		' by using return from the login call
  
  		'ERROR HERE.......................
  		
  		SessionHdr = oLogin.bfHeaderValue
  
  		'ERROR HERE	......................
  		
  		' Call the procedure to display login message according to login success level
  		loginMessage()
  		' If the login was successful and loggedIn was set to true
  		If loggedIn Then
			' Call procedure to display/hide appropriate panels in window once logged in
  			loggedInPanelDisplay()
  			' Test procedure to display the header values
  			loginTest()
  		Else
			' If unsuccessful login, exit this procedure, default back to details entry
  			Exit Sub
  		End If
  	End Sub
  
  	' Self-explanatory login return message procedure
  	' The message control "lblNotLoggedIn" only shows if needed, otherwise hidden
  	Private Sub loginMessage()
  		If SessionHdr.ReturnValue = 0 Then
  			loggedIn = True
  		ElseIf SessionHdr.ReturnValue = -1 Then
  			lblNotLoggedIn.Show()
  			lblNotLoggedIn.Text = "Site unavailable  "
  			loggedIn = False
  		Else
  			lblNotLoggedIn.Show()
  			lblNotLoggedIn.Text = "Not logged in  "
  			loggedIn = False
  		End If
  	End Sub
  	
  	Private Sub loggedInPanelDisplay()
  		If loggedIn Then
  			' Hide the login details panel and show who's logged in
			lblLoggedIn.Text = "Logged in as: " & SessionHdr.UserName
  			pnlLogin.Hide()
  			pnlLoggedIn.Show()
  		Else
			' If not logged in, blank login entry controls and await login
  			lblLoggedIn.Text = ""
  			pnlLogin.Show()
  			pnlLoggedIn.Hide()
  		End If
  	End Sub
  	' A procedure to display the  return header
  	' Not necessary to the solution but assists the developer see what's going on
  	Private Sub loginTest()
		lblLoginResp.Text = "sessionHdr = " & SessionHdr.ToString() & vbCrLf & _
  		    "UserName = " & SessionHdr.username.ToString() & vbCrLf & _
  		    "Password = " & SessionHdr.password.ToString() & vbCrLf & _
			"bfHeaderValue = " & SessionHdr.SessionID.ToString()
  	End Sub
  #End Region
  
  
  End Class
 
Back
Top