Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / December 2004

Tip: Looking for answers? Try searching our database.

problem setting up the security on my test web service

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg - 11 Dec 2004 22:00 GMT
Please note: I have cross posted this from Newsgroup:
microsoft.public.dotnet.framework.aspnet.webservices
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("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
Martin Kulov - 12 Dec 2004 12:52 GMT
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 - 13 Dec 2004 19:25 GMT
Grey wrote:

> The environment is:
> Running on local host.
[quoted text clipped - 4 lines]
> - Execute permissions = Scripts and executables
> - Application protection = Low

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.

> Hi Greg,
>
[quoted text clipped - 8 lines]
> MCSD.NET Early Achiever
> MCSD

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.