Web Services - ProtocolError

G

Guest

My goal is to use Windows Authentication (WA) to access sensitive web
services from a compact framework (CF) application. My web site on the
development server(IIS 6.0) is set to WA. I'm using O'Reilly's "Programming
..NET Web Services" as reference. I have created the web service, tested it
and shown that it works, and configuted its web.config file to to accomodate
WA by adding;

<authentication mode="Windows" />
<identity impersonate="true" />

Of course supplying credentials for the CF app is one of the challenges
since login is not a requirement on a PDA. THe O'Reilly book suggests that
the following code might be used in calling the web service:

mammoth.POE_WebServices wert = new PreProcEval.mammoth.POE_WebServices();
wert.Credentials = new NetworkCredential( "userid", "password", "domain" );
wert.PreAuthenticate = true;

String error = String.Empty;

try
{
DataSet myData = wert.POE_FindPatient( "Z99999", String.Empty,
String.Empty, error );

foreach( DataRow myRow in myData.Tables[0].Rows )
{
lvPatientSelector.Items.Add( new ListViewItem(
myRow.ItemArray[0].ToString() ));
}
}
catch( WebException wex )
{
MessageBox.Show( wex.Status.ToString() );
}

Notice the use of WebClientProtocol.Credentials to supply login in. MS
documentation says that the credentials can be used for "basic, digest, NTLM
and Kerberos authentication mechanisms". I'm assumming that Kerberos is
equivalent to WA, you may disabuse me if I'm wrong. Currently this code is
producing a WebException status of "ProtocolError" defined as "The response
received from the server was complete but indicated a protocol-level error.
For example, an HTTP protocol error such as 401 Access Denied would use this
status." In fact if I dig deeply enough into the WebException in the watch
window I find the 401 status code. Once again, I'm trolling for clues as to
what I'm missing here. (Thanks to Johann Granados for setting me on the
right path with yesterdays problem.)

Bill
 
J

Johann Granados

Hi Bill,

HTTP 401 errors has to do with authorization and not with authentication.
It means that your login is recognized as a known account but this account
doesn't have the right permissions to access the resource you are trying to
reach. To solve this problem you have to set the OS read and write
permission to the web application folder at the web server for the user you
are using to authenticate.

Hope this helps

Johann Granados
 

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

Top