Announcement Announcement Module
Collapse
No announcement yet.
Accessing web service through Acegi with Basic Authenticatio Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Accessing web service through Acegi with Basic Authenticatio

    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>(FileSystemXmlApplicationC ontext.java:83)
    at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.java:68)
    at org.springframework.context.support.FileSystemXmlA pplicationContext.<init>(FileSystemXmlApplicationC ontext.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

  • #2
    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...reService?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.

    Comment


    • #3
      Hi Chris,

      Do you have final resolution to the problem?

      Thanks.

      Comment


      • #4
        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

        Comment


        • #5
          Any new solutions?

          Since I also get the following exception:

          Code:
          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.http://www.protocol.http.HttpURLConn...tion.java:1133)
          	at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
          	at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(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(Unknown 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.populate(SymbolTable.java:420)
          	at org.jboss.axis.wsdl.gen.Parser$WSDLRunnable.run(Parser.java:273)
          This is my configuration:

          Code:
              <bean id="weatherService" class="org.springframework.remoting.jaxrpc.JaxRpcPortProxyFactoryBean">
                  <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

          Comment


          • #6
            Just out of curiosity did any of you figure this out?

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

            However i still get a 401 error using that.

            Comment

            Working...
            X