The remote server returned an error: (401) Unauthorized

T

Ted Bogucki

I get the following error when I try accessing my web server using iis
security. I uncheck allow anonymous access. I am using a windows xp
computer with .net 1.1 and all latest microsoft updates. I am using
..Visual Stusdio 2003 to write the WEB service and the client application.

System.Web.Services.Protocols.SoapException: System.Net.WebException: The
remote server returned an error: (401) Unauthorized.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials
credentials)
at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type
ofObjectToReturn)
at System.Xml.XmlTextReader.CreateScanner()
at System.Xml.XmlTextReader.Init()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlReader.MoveToContent()
at System.Data.DataSet.ReadXmlSchema(XmlReader reader, Boolean
denyResolving)
at System.Data.DataSet.ReadXmlSchema(String fileName)
at pmws002.pmJobEntry.SubmitXmlJob(DataSet inXml) in
C:\Inetpub\wwwroot\pmws002\pmJobEntry.asmx.vb:line 100
at
System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage
message, WebResponse response, Stream responseStream, Boolean asyncCall)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String
methodName, Object[] parameters)
at TestjobXML.pmws002.pmJobEntry.SubmitXmlJob(DataSet inXml) in
D:\VSS_Spot\TestjobXML\Web References\pmws002\Reference.vb:line 42
at TestjobXML.frmTestJobXML.btnImport_Click(Object sender, EventArgs e)
in D:\VSS_Spot\TestjobXML\Form1.vb:line 162

If I specify an invalid password I get a different error.

I can set the user that I am trying to use as the anuonymous user and it
works. I tried unchecking windows integrated authentication but it did not
help.

here is thee code I am using to access the web service

Dim myDataset As DataSet = New DataSet

Dim errDataSet As DataSet = New DataSet

Dim pw As pmws002.pmJobEntry = New pmws002.pmJobEntry

If chkLogin.Checked = True Then

Dim myCred As NetworkCredential = New NetworkCredential

myCred.UserName = txtUser.Text

myCred.Password = txtPasswd.Text

Dim myCredCache As CredentialCache = New CredentialCache

myCredCache.Add(New Uri(pw.Url), "Basic", myCred)

pw.Credentials = myCredCache

End If

Dim fLnm As String = "samples\test.xml"

Dim ErrMsg As String

Try

myDataset.ReadXml(fLnm)

Catch ex As Exception

End Try

Try

'errDataSet = lSubmitXmlJob(myDataset)

errDataSet = pw.SubmitXmlJob(myDataset)

If errDataSet.Tables("status").Rows(0).Item("Succeeded") Then

MsgBox("Job Imported Successfully")

End If

'MsgBox(errDataSet.Tables("status").Rows(0).Item("Succeeded"))

Catch ex As Exception

If errDataSet Is Nothing Then

MsgBox("ErrDataSet is nothing")

End If

TextBox1.Text = ex.ToString

MsgBox(ex.ToString)

End Try
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top