simple problem setting up the security on my test web service

Discussion in 'ASP .Net Web Services' started by Greg, Dec 11, 2004.

  1. Greg

    Greg Guest

    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
     
    Greg, Dec 11, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wym
    Replies:
    0
    Views:
    226
  2. Kondratyev Denis

    Tools for test web service security

    Kondratyev Denis, Jun 23, 2004, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    98
    Michelle Hlaing
    Feb 23, 2005
  3. Greg
    Replies:
    0
    Views:
    113
  4. A.M-SG
    Replies:
    4
    Views:
    442
    Steven Cheng[MSFT]
    Oct 6, 2005
  5. news.microsoft.com

    SSL for very simple security need in web service app

    news.microsoft.com, Oct 18, 2005, in forum: ASP .Net Web Services
    Replies:
    3
    Views:
    152
    Rob Schripsema
    Oct 18, 2005
Loading...

Share This Page