Using a Web Service call within a VB Module

K

Kirk

I have a WS called "IWeb", which I define within the page class like
this:

Dim service As IWeb.WebService

I then have a button that calls the web service like this:

Dim header As IWeb.IWebAuthendicationHeader = New
IWeb.IWebAuthendicationHeader()
Dim strName As String = Request.ServerVariables("LOGON_USER")
header.Username = strName
header.Password = "ThisPW"
header.Encrypted = "True"

service = New IWeb.WebService()
service.IWebAuthendicationHeaderValue = header

Dim result As String = String.Empty

result = service.IsUserHere(My.Settings.WS_Role_Admins)

lblWSResult.Text = result

This works (with the code within the page-behind section), but I
really need this code to reside within a VB code MODULE. However, as
soon as I try to do this, I start getting errors. If I even add the
"Dim service As IWeb.WebService" definition, it gives me this error:
"Type 'IWeb.WebService' is not defined."

I have tried moving this definition to different areas within the
module's class, but I can't seem to get past this error. I think this
is one of those things where you can't call certain procedures outside
of a page's code-behind file (?). I have also experimented with
adding an Imports statement at the start of my module's class, with
similar errors.

I would greatly appreciate any suggestions & again, sorry for posting
a non-AJAX question.

Thank you!
 
J

John Saunders [MVP]

Kirk said:
I have a WS called "IWeb", which I define within the page class like
this:

Dim service As IWeb.WebService

I then have a button that calls the web service like this:

Dim header As IWeb.IWebAuthendicationHeader = New
IWeb.IWebAuthendicationHeader()
Dim strName As String = Request.ServerVariables("LOGON_USER")
header.Username = strName
header.Password = "ThisPW"
header.Encrypted = "True"

service = New IWeb.WebService()
service.IWebAuthendicationHeaderValue = header

Dim result As String = String.Empty

result = service.IsUserHere(My.Settings.WS_Role_Admins)

lblWSResult.Text = result

This works (with the code within the page-behind section), but I
really need this code to reside within a VB code MODULE. However, as
soon as I try to do this, I start getting errors. If I even add the
"Dim service As IWeb.WebService" definition, it gives me this error:
"Type 'IWeb.WebService' is not defined."

I have tried moving this definition to different areas within the
module's class, but I can't seem to get past this error. I think this
is one of those things where you can't call certain procedures outside
of a page's code-behind file (?). I have also experimented with
adding an Imports statement at the start of my module's class, with
similar errors.

I would greatly appreciate any suggestions & again, sorry for posting
a non-AJAX question.

In general, you should avoid VB modules. They are not object-oriented, and
are effectively Shared classes without inheritance.

In this case, the question is, "why _isn't_ 'IWeb.WebService' defined? Did
you Import the namespace it is a part of?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top