Connecting Tech Pros Worldwide Forums | Help | Site Map

problem setting up the security on my test web service

Greg
Guest
 
Posts: n/a
#1: Nov 23 '05
Please note: I have cross posted this from Newsgroup:
microsoft.public.dotnet.framework.aspnet.webservic es
with a few minor changes...

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

<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 win forms 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("c ode"), _
System.Web.Services.WebServiceBindingAttribute(Nam e:="AddNumbersWebServiceSoap",
[Namespace]:="http://tempuri.org/AddNumbersWebService/AddNumbersWebService")>
_
Public Class AddNumbersWebService
Inherits System.Web.Services.Protocols.SoapHttpClientProtoc ol

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

'<remarks/>
<System.Web.Services.Protocols.SoapDocumentMethodA ttribute("http://tempuri.org/AddNumbersWebService/AddNumbersWebService/AddNumbers",
RequestNamespace:="http://tempuri.org/AddNumbersWebService/AddNumbersWebService",
ResponseNamespace:="http://tempuri.org/AddNumbersWebService/AddNumbersWebService",
Use:=System.Web.Services.Description.SoapBindingUs e.Literal,
ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.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

Martin Kulov
Guest
 
Posts: n/a
#2: Nov 23 '05

re: problem setting up the security on my test web service


Hi Greg,

You must allow anonymous access to your virtual directory in IIS management console.

Regards,

Martin Kulov
http://www.codeattest.com

MCAD Charter Member
MCSD.NET Early Achiever
MCSD


Mujtaba Syed
Guest
 
Posts: n/a
#3: Nov 23 '05

re: problem setting up the security on my test web service


Grey wrote:
[color=blue]
> 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[/color]

Greg, even though you have said that 'anonymous access is allowed', Martin's
answer holds good. If you check closely, I suspect both the anonymous access
and the integrated windows authentication checkboxes will be checked.
Uncheck the integrated windows authentication checkbox and your web service
will become usable by Windows Forms applications.

Mujtaba.

"Martin Kulov" <kulov@bezbokluk.abv.bg> wrote in message
news:%23s9e%23lE4EHA.3380@TK2MSFTNGP09.phx.gbl...[color=blue]
> Hi Greg,
>
> You must allow anonymous access to your virtual directory in IIS[/color]
management console.[color=blue]
>
> Regards,
>
> Martin Kulov
> http://www.codeattest.com
>
> MCAD Charter Member
> MCSD.NET Early Achiever
> MCSD
>
>[/color]


Closed Thread