Re: Error calling web service

From: Scott Allen (bitmask_at_[nospam)
Date: 08/17/04


Date: Tue, 17 Aug 2004 00:09:39 -0400

It looks as if the web service requires credentials to authenticate
the incoming request. From a client application you can pass
credentials along with the request:

ws.Credentials = System.Net.CredentialCache.DefaultCredentials;

DefaultCredentials will represent the credentials of the user running
the client process.

HTH,

--
Scott
http://www.OdeToCode.com
On Tue, 17 Aug 2004 01:20:14 +0100, "John" <john@nospam.infovis.co.uk>
wrote:
>Hi
>
>My first web service seems to be OK as I can put its url in explorer and can
>use the invoke button to view the returned data as xml. The problem comes
>when I call it form a client app using;
>
>Dim ws As New localhost.StaffWS
>Dim ds = ws.GetStaffDiary
>
>When the second line above is executed I get a 'The request failed with HTTP
>status 401: Access Denied.' error on the line indicated below in the
>\webreferences\localhost\references.vb file on the line indicated below;
>
><System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost
>/staff/staffws/StaffWS.asmx/GetStaffDiary",
>RequestNamespace:="http://localhost/staff/staffws/StaffWS.asmx",
>ResponseNamespace:="http://localhost/staff/staffws/StaffWS.asmx",
>Use:=System.Web.Services.Description.SoapBindingUse.Literal,
>ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _
>Public Function GetStaffDiary() As System.Data.DataSet
>    Dim results() As Object = Me.Invoke("GetStaffDiary", New Object(-1) {})
>'<== This line has the error.
>    Return CType(results(0),System.Data.DataSet)
>End Function
>
>Any idea what this error is about and how to fix it?
>
>Thanks
>
>Regards
>