Web Service Problem...
-
I’m creating my first web service and running into the following error. A first chance exception of type 'System.Net.WebException' occurred in system.dll Additional information: The remote server returned an error: (401) Unauthorized. The error occurs in the Reference.vb file when I try to retrieve a string value from a function in the asmx file. Here is some of the code from the Reference.vb file.
<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/XMLWebServices/ReturnValue", RequestNamespace:="http://localhost/XMLWebServices ", ResponseNamespace:="http://localhost/ XMLWebServices ", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _ Public Function ReturnValue() As String Dim results() As Object = Me.Invoke("ReturnValue", New Object(-1) {}) Return CType(results(0), String) End Function
The web method in the asmx file looks like the following.<WebMethod()> Public Function ReturnValue() As String ReturnValue = "Value" End Function
All suggestions are greatly appreciated. Jason W. -
I’m creating my first web service and running into the following error. A first chance exception of type 'System.Net.WebException' occurred in system.dll Additional information: The remote server returned an error: (401) Unauthorized. The error occurs in the Reference.vb file when I try to retrieve a string value from a function in the asmx file. Here is some of the code from the Reference.vb file.
<System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://localhost/XMLWebServices/ReturnValue", RequestNamespace:="http://localhost/XMLWebServices ", ResponseNamespace:="http://localhost/ XMLWebServices ", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _ Public Function ReturnValue() As String Dim results() As Object = Me.Invoke("ReturnValue", New Object(-1) {}) Return CType(results(0), String) End Function
The web method in the asmx file looks like the following.<WebMethod()> Public Function ReturnValue() As String ReturnValue = "Value" End Function
All suggestions are greatly appreciated. Jason W.Must define Credentials
Dim ws As New localhost.WebS() ws.Credentials = System.Net.CredentialCache.DefaultCredentials
Jason W.