Archive for August 31st, 2008

Error 401 when using ObjectDatasource to call a web service

Recently, I used a ObjectDataSource object to call a web service from an ASP.Net web site. Much to my surprise, I got the following error when I run it:

The request failed with HTTP status 401: Unauthorized.

In addition, the error stated the routine resulted in the following source error:

Line 111:        [return: System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
Line 112:        public string Test() {
Line 113:            object[] results = this.Invoke(“Test”, new object[0]);
Line 114:            return ((string)(results[0]));
Line 115:        }

Apparently, the error occur in line 113, when the web service is invoked. What is annoying is that the error does not appear in the security event log. Reading the IIS log file did not result in further understanding. This post did however gave me a big clue.

What appears to be happening is that the authentication credentials are not being passed to the web service. One would expect that with reflection, the ObjectDataSource would have some seamless way to pass the credentials, but there is not. You will have to create an instance of the web service proxy. A good place to do this is when the ObjectDataSource is being created. Double-click on your objectDataSource’s Object Creating event. This will create an event handler.

protected void MyObjDS_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
{
MyWebService.Service webProxy = new MyWebService.Service();
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
e.ObjectInstance = webProxy;
}

In the above example, I am passing my default credential to the web service. This occur was the ObjectDataSource is being created. Note that I am assuming that the URL of the webProxy is already set when you added the web service as a web reference. If you have different web service for each environment (dev, test, prod, etc), you can put the URL in the web.config and add an additional line to set the URL.

protected void MyObjDS_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
{
MyWebService.Service webProxy = new MyWebService.Service();
webService.Url = ConfigurationManager.AppSettings["MyWebServiceURL"];
webProxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
e.ObjectInstance = webProxy;
}

4 comments August 31, 2008

Fixing “Carrier Stall” error on a Lexmark Z52 Printer

Recently, my Lexmark Z52 stop printing. Whenever I print, I would get the error “Carrier Stall”. The problem was not resolved when I reset the printer several times. I also tried reinstalling the cartridge, but that did not help.

I did some google search and discover the following knowledge base issue. From what I can determine, there is a clear plastic strip right behind the print carriage (where your ink cartridge sits) that the printer reads as it prints. If this cartridge is unreadable, you could get a “Carriage Stall” error or the carriage starts slamming itself against the side of the printer.

The knowledge base article suggest flicking it. This did not help and it would appear that the strip was in place properly. I got out some wet paper towel and carefully wiped it down and then make sure it was back in alignment. This did not immediately fixed the problem, but I figure there was probably some moisture on the strip. I waited overnight for the strip to dry and tried again. This time, the printer worked perfectly.

While I do not guarantee that this will fix your printer, why not give it a try. It cost nothing and it may save another printer from going into the landfill.

Add comment August 31, 2008


Calendar

August 2008
M T W T F S S
« Jul   Sep »
 123
45678910
11121314151617
18192021222324
25262728293031

Posts by Month

Posts by Category