PDA

View Full Version : Accessing web service through Acegi with Basic Authenticatio



Chris Snape
Dec 15th, 2004, 04:33 AM
I have successfully set up and installed a web service within an Orion web server using Axis. I have been able to communicate with the web service using some client code based on the jpetstore example.

I am now trying to make the application more secure using Acegi so that any attempt to access the web service requires Basic Authentication. The web service still works correctly when I access it through code generated via .NET, Axis (WSDL2Java) and JDeveloper.

However, when I try to access the same web service using the code based upon the jpetstore example I get the following error:

org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'jaxRpcProxy' defined in file [C:\CPS\IdeaProjects\SupportSystem\clientTicketCont ext.xml]: Initialization of bean failed; nested exception is javax.xml.rpc.ServiceException: Error processing WSDL document:
java.io.IOException: Server returned HTTP response code: 401 for URL: http://xxxx/supportsystem/ssint/soap/TicketService?wsdl
javax.xml.rpc.ServiceException: Error processing WSDL document:
java.io.IOException: Server returned HTTP response code: 401 for URL: http://xxxx/supportsystem/ssint/soap/TicketService?wsdl
at org.apache.axis.client.Service.initService(Service .java:278)
at org.apache.axis.client.Service.<init>(Service.java:193)
at org.apache.axis.client.ServiceFactory.createServic e(ServiceFactory.java:232)
at org.springframework.remoting.jaxrpc.LocalJaxRpcSer viceFactory.createJaxRpcService(LocalJaxRpcService Factory.java:152)
at org.springframework.remoting.jaxrpc.JaxRpcPortClie ntInterceptor.afterPropertiesSet(JaxRpcPortClientI nterceptor.java:225)
at org.springframework.remoting.jaxrpc.JaxRpcPortProx yFactoryBean.afterPropertiesSet(JaxRpcPortProxyFac toryBean.java:55)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.invokeInitMethods(Abstr actAutowireCapableBeanFactory.java:1057)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:287)
at org.springframework.beans.factory.support.Abstract AutowireCapableBeanFactory.createBean(AbstractAuto wireCapableBeanFactory.java:205)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:204)
at org.springframework.beans.factory.support.Abstract BeanFactory.getBean(AbstractBeanFactory.java:136)
at org.springframework.beans.factory.support.DefaultL istableBeanFactory.preInstantiateSingletons(Defaul tListableBeanFactory.java:230)
at org.springframework.context.support.AbstractApplic ationContext.refresh(AbstractApplicationContext.ja va:284)
at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationContext.java:83)
at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationContext.java:68)
at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationContext.java:59)
at com.easynet.supportsystem.client.modules.ticket.so ap.TicketServiceClient.main(TicketServiceClient.ja va:71)

Any feedback on this problem would be appreciated.

Regards,

Chris

RayKrueger
Dec 15th, 2004, 09:12 AM
I had the same problem a week or two back, I was only experimenting with some ideas though so I didn't pursue it any further. I unfortunately cannot offer a solution, only a little more information on the problem.

The problem begins in JaxRpcPortClientInterceptor.afterPropertiesSet().

At line 263 (in 1.1.2) a call is made to
this.jaxRpcService = createJaxRpcService();

The createJaxRpcService (inherited from LocalJaxRpcServiceFactory) method calls off to the serviceFactory.createService() method.

Unforutanetly the injected username and password properties are never passed along to the serviceFactory for when it tries to read the wsdl information.

The username and password properties don't get used until later on after the stub is built.



One possible work around is to save your wsdl doc to a local file and point to it with a file:/ url. That will probably upset axis and the namespaces though.

Another really ugly work around would be to put the usrname and password in the wsdl url itself
http://username:password@server:8080/axis/MySecureService?wsdl
(hey, I said it was ugly)

I'm more or less babbling about this hoping someone comes up with a fix :P
I may not get a chance to suggest one today.

UserStephen
Jul 1st, 2005, 07:55 AM
Hi Chris,

Do you have final resolution to the problem?

Thanks.

sjivan
Jul 5th, 2005, 05:39 AM
The problem is that your WSDL url should be publicly available and not be a protected URL.

The service endpoint is the one that should be protected. Setting the username and password on the client JaxRpcPortProxyFactoryBean bean would effectively pass on the credentials to the actual invocation.

You can configure Acegi to exclude the WSDL url from being protected.

Sanjiv

alesj
Oct 28th, 2005, 09:21 AM
Any new solutions?

Since I also get the following exception:


ERROR [Service] Server returned HTTP response code: 401 for URL: http://x.y.net/g/services/weatherservice.wsdl
java.io.IOException: Server returned HTTP response code: 401 for URL: http://x.y.net/g/services/weatherservice.wsdl
at sun.net.www.protocol.http.HttpURLConnection.getInp utStream(HttpURLConnection.java:1133)
at org.apache.xerces.impl.XMLEntityManager.setupCurre ntEntity(Unknown Source)
at org.apache.xerces.impl.XMLVersionDetector.determin eDocVersion(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(U nknown Source)
at org.jboss.axis.utils.XMLUtils.newDocument(XMLUtils .java:274)
at org.jboss.axis.utils.XMLUtils.newDocument(XMLUtils .java:322)
at org.jboss.axis.wsdl.symbolTable.SymbolTable.popula te(SymbolTable.java:420)
at org.jboss.axis.wsdl.gen.Parser$WSDLRunnable.run(Pa rser.java:273)


This is my configuration:



<bean id="weatherService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProx yFactoryBean">
<property name="serviceInterface">
<value>com.h.g.services.IWeatherService</value>
</property>
<property name="portInterface">
<value>com.h.g.services.IWeatherPortService</value>
</property>
<property name="wsdlDocumentUrl">
<value>http://x.y.net/g/services/weatherservice.wsdl</value>
</property>
<property name="namespaceUri">
<value>http://x.y.net/g/services/weatherservice</value>
</property>
<property name="serviceName" value="WeatherServiceImpl"/>
<property name="portName" value="IWeatherService" />
<property name="username" value="user" />
<property name="password" value="pass" />
</bean>


Username and password anre definitely correct.

Rgds, Ales

jnusaira
May 2nd, 2006, 02:11 PM
Just out of curiosity did any of you figure this out?

I tried adding the http://username:password*url.com/?WSDL

However i still get a 401 error using that.