1 Reply Latest reply on Jun 27, 2011 10:18 PM by njiang

    Simple authentication with SpringBusFactory?

    jamie3_james.archibald

      I am trying to connect to a web service as follows (using wsdl2java):

       

      https://username:password@someserver:1234/WS/v2/RepositoryService

       

      Here is how I am connecting:

       

      SpringBusFactory bf = new SpringBusFactory();

      uRL busFile = CpofWebServiceUtils.class.getResource("cxf-config.xml");

      Bus bus = bf.createBus(busFile.toString());

      bf.setDefaultBus(bus);

               

               

      RepositoryService_Service rsp = new RepositoryService_Service(new URL(WSDL_URL), SERVICE_NAME);          

      RepositoryService svc = rsp.getPort(PORT_NAME, RepositoryService.class);

                 

       

      In my pom I am including cxf-rt-core and cxf-rt-transports-http.

       

      My cxf-config.xml looks as follows:

       

        <http:conduit name="RepositoryServicePort.http-conduit">

                       <http:authorization>

                    <sec:UserName>username</sec:UserName>

                    <sec:Password>password</sec:Password>

                 </http:authorization>

         </http:conduit>

       

       

      I can connect to the WS no problem, but when a method is invoked I get the following exception:

       

      com.sun.xml.internal.ws.client.ClientTransportException: The server sent HTTP status code 401: Unauthorized

       

      Edited by: jamie3 on Jun 27, 2011 11:44 AM