weird axis2 errors

Tue, Sep 4, 2007

I was accessing the Fedora API-A web services using XMLBeans that I’d created from the WSDL (more on that later) but I kept getting weird errors:

org.apache.axis2.AxisFault: Transport error: 302 Error: Moved Temporarily

Turned out I was half asleep and was accessing the wrong URL:

it should have been:

The next error I was getting was this really weird one: problem accessing the parser. Parser already accessed!

After much head scratching and cake munching I saw a post somewhere that triggered something. I’m using authenticated, secure web services with Fedora. If you use the REST interface you get a BASIC authentication box coming up in the browser asking for the username and password. But I wasn’t using the browser, I was using the service client that was generated by XMLBeans. Apparently Axis2 will not send the username and password unless it’s asked to do so. So when the request hits the protected service without any credentials, the client basically barfs with this error.

The solution was to use HttpTransportProperties.Authenticator.setPreemptiveAuthentication(true)

this causes the client to send the credentials with the request. And it all works now :)

FWIW here’s some of the code that supports HTTPS and BASIC auth for a web service request:

I’d previously set up the Fedora desktop client to support HTTPS using its truststore, so I just reused that in the web services client test:

System.setProperty(“”, “/Users/alistair/apps/fedora/client/truststore”); System.setProperty(“”, “tomcat”);

FedoraAPIAServiceStub stub = new FedoraAPIAServiceStub(“”);

HttpTransportProperties.Authenticator authenticator = new HttpTransportProperties.Authenticator(); authenticator.setUsername(“fedoraAdmin”); authenticator.setPassword(“hohoho”); authenticator.setPreemptiveAuthentication(true);

stub._getServiceClient().getOptions().setProperty(HTTPConstants.AUTHENTICATE, authenticator);

DescribeRepositoryResponseDocument outDoc = stub.describeRepository(doc);

comments powered by Disqus