simple problem setting up the security on my test web service

G

Greg

I am having a simple problem setting up the security on my test web
service...

My Web service code is:

Imports System.Web.Services
<System.Web.Services.WebService(Namespace :=
"http://tempuri.org/AddNumbersWebService/AddNumbersWebService")> _
Public Class AddNumbersWebService
Inherits System.Web.Services.WebService
#Region " Web Services Designer Generated Code "
<WebMethod()> _
Public Function AddNumbers( ByVal a1 As Integer, _
ByVal a2 As Integer) As String
Dim lResult As String = (A1+A2).ToString
Return lResult
End Function
End Class

This works fine when I test it using F5, it fires up a web page where
I can test the web service. But when I try to write a client
program...

Private Sub DoIt
Try
TextBox3.Text = "Processing"
Application.DoEvents
Dim lV1 As String = TextBox1.Text
Dim lV2 As String = TextBox2.Text
Dim lV1a As Integer = 0
Dim lV2a As Integer = 0
If IsNumeric( lV1 ) Then lV1a = Int( lV1 )
If IsNumeric( lV2 ) Then lV2a = Int( lV2 )
Dim lWebService As New
WebServiceClient.localhost.AddNumbersWebService
Dim lResult As String = lWebService.AddNumbers(lV1a,lV2a)
TextBox3.Text = lResult
Catch ex As Exception
TextBox3.Text = ex.Message
End Try
End Sub

I get the error "The request failed with HTTP status 401: Access
Denied." from the line:
Dim lResult As String = lWebService.AddNumbers(lV1a,lV2a)

I think this is a simple setup problem with the IIS security settings
but I cannot figure it out. Any help would be appreciated.

The environment is:
Running on local host.
VB2003.
MS Windows-XP (SP1)
For the web service:
- anonymous access is allowed.
- Execute permissions = Scripts and executables
- Application protection = Low

Thanks in advance for your help
Greg

p.s. the reference.vb file contains...
Imports System
Imports System.ComponentModel
Imports System.Diagnostics
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Xml.Serialization

'
'This source code was auto-generated by Microsoft.VSDesigner, Version
1.1.4322.573.
'
Namespace localhost1

'<remarks/>
<System.Diagnostics.DebuggerStepThroughAttribute(), _
System.ComponentModel.DesignerCategoryAttribute("code"), _
System.Web.Services.WebServiceBindingAttribute(Name:="AddNumbersWebServiceSoap",
[Namespace]:="http://tempuri.org/AddNumbersWebService/AddNumbersWebService")>
_
Public Class AddNumbersWebService
Inherits System.Web.Services.Protocols.SoapHttpClientProtocol

'<remarks/>
Public Sub New()
MyBase.New
Me.Url =
"http://localhost/AddNumbersWebService/AddNumbersWebService.asmx"
End Sub

'<remarks/>
<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/AddNumbersWebService/AddNumbersWebService/AddNumbers",
RequestNamespace:="http://tempuri.org/AddNumbersWebService/AddNumbersWebService",
ResponseNamespace:="http://tempuri.org/AddNumbersWebService/AddNumbersWebService",
Use:=System.Web.Services.Description.SoapBindingUse.Literal,
ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)>
_
Public Function AddNumbers(ByVal a1 As Integer, ByVal a2 As
Integer) As String
Dim results() As Object = Me.Invoke("AddNumbers", New
Object() {a1, a2})
Return CType(results(0),String)
End Function

'<remarks/>
Public Function BeginAddNumbers(ByVal a1 As Integer, ByVal a2
As Integer, ByVal callback As System.AsyncCallback, ByVal asyncState
As Object) As System.IAsyncResult
Return Me.BeginInvoke("AddNumbers", New Object() {a1, a2},
callback, asyncState)
End Function

'<remarks/>
Public Function EndAddNumbers(ByVal asyncResult As
System.IAsyncResult) As String
Dim results() As Object = Me.EndInvoke(asyncResult)
Return CType(results(0),String)
End Function
End Class
End Namespace
 

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,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top