473,322 Members | 1,614 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Web Service 401 not authorized error?

I have create a small WebService on VB.NET that is giving me problems trying
to call it. It tests fine running it directly from VS.NET 2003 but when I
try to call it from another vb.net app it gives me an http 401 unauthorized
message. The webservice and the vb.net windows app are both on my
development box. Here is the code that is having the problem: This line
gives the error: Dim results() As Object = Me.Invoke("GetCustomers", New
Object() {sCountryCode})

This code is in the Reference.vb file for the webservice
<System.Web.Services.Protocols.SoapDocumentMethodA ttribute("http://localhost
/Northwind/Customer/GetCustomers",
RequestNamespace:="http://localhost/Northwind/Customer",
ResponseNamespace:="http://localhost/Northwind/Customer",
Use:=System.Web.Services.Description.SoapBindingUs e.Literal,
ParameterStyle:=System.Web.Services.Protocols.Soap ParameterStyle.Wrapped)> _

Public Function GetCustomers(ByVal sCountryCode As String) As
System.Data.DataSet

Dim results() As Object = Me.Invoke("GetCustomers", New Object()
{sCountryCode})

Return CType(results(0),System.Data.DataSet)

End Function

The webservice code is this:

Imports System.Web.Services

Imports System.Data

Imports System.Data.SqlClient

<System.Web.Services.WebService(Namespace:="http ://localhost/Northwind/Custo
mer")> _

Public Class Customer

Inherits System.Web.Services.WebService

#Region " Web Services Designer Generated Code "

Public Sub New()

MyBase.New()

'This call is required by the Web Services Designer.

InitializeComponent()

'Add your own initialization code after the InitializeComponent() call

End Sub

'Required by the Web Services Designer

Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Web Services Designer

'It can be modified using the Web Services Designer.

'Do not modify it using the code editor.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

'CODEGEN: This procedure is required by the Web Services Designer

'Do not modify it using the code editor.

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

#End Region

<WebMethod()> _

Public Function GetCustomers(ByVal sCountryCode As String) As DataSet

Dim cnn As SqlConnection = New SqlConnection("Data Source=(local);Initial
Catalog=Northwind;Integrated Security=SSPI")

Dim cmd As SqlCommand = cnn.CreateCommand

cmd.CommandType = CommandType.Text

cmd.CommandText = "Select * from Customers where Country = '" & sCountryCode
& "'"

Dim da As SqlDataAdapter = New SqlDataAdapter(cmd)

Dim dsCustomerData As DataSet = New DataSet

da.Fill(dsCustomerData, "Customers")

GetCustomers = dsCustomerData

End Function

End Class

Here is the code to call it.
Private Sub btnGetCustomerData_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles btnGetCustomerData.Click

Dim dsCustomers As DataSet

Dim cust As localhost.Customer = New localhost.Customer

dsCustomers = cust.GetCustomers("France")

dgCustomers.DataSource = dsCustomers

dgCustomers.DataMember = "Customers"

End Sub

Jul 21 '05 #1
0 1322

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jeff | last post by:
Hi, I have an ASP.NET web application that streams PDF output to a new instance of the browser. Using version 6 of Internet Explorer there are no problems. Using version 6 Service Pack 1...
7
by: sidd | last post by:
Hi All, i have some doubts on .net windows services.. please see if some one could help me understand this.. 1)is it possible to install a windows service which does not have a installer added...
2
by: John Lee | last post by:
Hi, I have a web service setup as "Integrated Windows Authentication" only, How can I set the credential to call the web service from Windows application? I tried to create the proxy, and the...
4
by: Bruce | last post by:
I am developing an ASP.NET web service application. It works fine on my WinXP Prof development machine. But when I send it to a Windows Server 2003 system I get the following error (attached...
2
by: Jon | last post by:
Hi all, I'm trying to call a web service from an asp.net (v1.1) page written in C# (the web service was written in C# too) and I keep getting a "The request failed with HTTP status 401:...
5
by: Robin Mark Tucker | last post by:
I'm wondering what arguments you people might have for/against implementing an internet based system via. either Virtual Private Network (ie. the client thinks it's local) or via. a Web Service. ...
27
by: pisquem | last post by:
I am building an windows service that is to be deployed on a windows server 2003 and I want to have activity written to the event log, I want its own log called ('CustomLog') Below is what I...
0
by: JeremyPollack | last post by:
Here's the situation : I have the same ASP.NET 2.0 web application running on both Machine A and Machine B. On both machines, I have Integrated Windows Authentication turned on, and Anonymous...
3
by: ssg31415926 | last post by:
I'm getting the error: "Unable to open the Web 'http://blah/blahblah'. You are not authorized to perform the current operation". I have changed a few things recently but I can't change them back...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.