10 Replies Latest reply on Oct 9, 2012 5:17 AM by pestar

    how can i access a web service with basic authentication

    pestar

      hi,

      i have to access a web service that is using basic http authentication.

      here is my blueprint.xml:

       

       

       

       

       

       

       

      but how can i set the the username and password in the http header?

       

      can anyone help?

      thanks peter

        • 1. Re: how can i access a web service with basic authentication
          davsclaus

          Hi

           

          Have you checked the security guide at

          http://fusesource.com/products/fuse-esb-enterprise/#documentation

           

          It should cover the camel-cxf component also.

          • 2. Re: how can i access a web service with basic authentication
            pestar

            thank you for the answer.

            i have now checked the security guide you pointed me to. but i'm not sure if i understand this all right. my approach is now to add a http-conduit to my blueprint.xml file. i added this:

             

             

             

             

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

                      <http:authorization>

                           <sec:UserName>user</sec:UserName>

                           <sec:Password>pass</sec:Password>

                      </http:authorization>

            </http:conduit>

             

             

            is this the right approach? how does the cxf-endpoint know about the http-conduit?

             

            one additional question. if i try to deploy this on servicemix, log says :

            "Bundle blueprint.xml is waiting for namespace handlers "

            which other features have to installed? here is the list of features i already have installed:

            karaf-framework

            spring

            spring-dm

            spring-jms

            spring-oxm

            spring-tx

            spring-web

            config

            jetty

            http

            war

            camel-activemq

            activemq-broker

            activemq

            activemq-spring

            activemq-blueprint

            xml-specs-api

            came

            camel-core

            camel-spring

            camel-blueprint

            camel-cxf

            camel-http

            camel-http4

            camel-jms

            camel-jaxb

            camel-ldap

            camel-soap

            camel-spring-security

            camel-spring-ws

            cxf-specs

            cxf-jaxb

            cxf-abdera

            opensaml

            wss4j

            cxf-saaj-impl

            cxf-war-java5

            cxf

             

             

            thanks for helping

            peter

            • 3. Re: how can i access a web service with basic authentication
              njiang

              CXF runtime will pick up the conduite configuration when it starts to invoke the service.

               

              You need to install the cxf feature to pick up the bluepring namespace handler, if you are using camel-cxf at the same time, you just need to install the camel-cxf feature and it will install the cxf feature by default.

               

              Willem

              • 4. Re: how can i access a web service with basic authentication
                davsclaus

                What version of Fuse ESB are you using?

                • 5. Re: how can i access a web service with basic authentication
                  pestar

                  willem, thank you for the answer.

                  i have the cxf and camel-cxf features installed.

                  after switching logging to debug mode i see this message:

                   

                  Sending blueprint container event BlueprintEvent[type=GRACE_PERIOD, dependencies=[(&(objectClass=org.apache.aries.blueprint.NamespaceHandler)(osgi.service.blueprint.namespace=http://cxf.apache.org/transports/http/configuration)), (&(objectClass=org.apache.aries.blueprint.NamespaceHandler)(osgi.service.blueprint.namespace=http://cxf.apache.org/configuration/security))]] for bundle blueprint.xml

                   

                  do you have an advice for me, how to overcome this?

                   

                  thanks

                  peter

                  • 6. Re: how can i access a web service with basic authentication
                    pestar

                    i'm using apache-servicemix-4.4.1-fuse-07-11

                    • 7. Re: how can i access a web service with basic authentication
                      ffang

                      Hi,

                       

                      apache-servicemix-4.4.1-fuse-07-11 is using cxf 2.4.x underlying, which doesn't have blueprint http configuration support yet. Since CXF 2.5.x it has blueprint support, so please use FUSE ESB 7.x if possible.

                       

                      Freeman

                      • 8. Re: how can i access a web service with basic authentication
                        pestar

                        thank you very much freeman.

                         

                        unfortunately i don't have access to fuse esb 7.x at the moment. so i installed karaf 2.2.9, cxf 2.6.2 and camel 2.10.1.

                        even though i can deploy my blueprint without issues now, i get following error if the route is started:

                        | ERROR | ault-workqueue-1 | DefaultErrorHandler              | 88 - org.apache.camel.camel-core - 2.10.1 | Failed delivery for (MessageId: ID-psmac-49221-1349764429947-11-3 on ExchangeId: ID-psmac-49221-1349764429947-11-2). Exhausted after delivery attempt: 1 caught: org.apache.cxf.transport.http.HTTPException: HTTP response '401: Unauthorized' when communicating with http://psimac:8080/MyWebApp/MyService

                        org.apache.cxf.transport.http.HTTPException: HTTP response '401: Unauthorized' when communicating with http://psimac:8080/MyWebApp/MyService

                             at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1619)[139:org.apache.cxf.cxf-rt-transports-http:2.6.2]

                             at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream$1.run(HTTPConduit.java:1535)[139:org.apache.cxf.cxf-rt-transports-http:2.6.2]

                             at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$3.run(AutomaticWorkQueueImpl.java:426)[127:org.apache.cxf.cxf-api:2.6.2]

                             at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)[:1.6.0_35]

                             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)[:1.6.0_35]

                             at org.apache.cxf.workqueue.AutomaticWorkQueueImpl$AWQThreadFactory$1.run(AutomaticWorkQueueImpl.java:351)[127:org.apache.cxf.cxf-api:2.6.2]

                             at java.lang.Thread.run(Thread.java:680)[:1.6.0_35]

                         

                        i did a tcp dump and here is the extract where the service is called:

                         

                        POST /JAXWSWebApp/MathService HTTP/1.1

                        Content-Type: text/xml

                        Accept: /

                        breadcrumbId: ID-psmac-49221-1349764429947-11-1

                        User-Agent: Apache CXF 2.6.2

                        Cache-Control: no-cache

                        Pragma: no-cache

                        Host: psimac:8080

                        Connection: keep-alive

                        Content-Length: 240

                         

                         

                         

                         

                             <http:conduit name="myService.http-conduit"

                                  xmlns:sec="http://cxf.apache.org/configuration/security"

                                     xmlns="http://cxf.apache.org/transports/http/configuration">

                                   

                         

                        what am i missing here?

                         

                        btw. i did another test with a java client (metro) and it worked perfectly.

                         

                        thanks for your help!

                        peter

                        • 9. Re: how can i access a web service with basic authentication
                          ffang

                          Hi,

                           

                          The error comes from that your http:conduit configuration didn't get picked up by correct port, the http:conduit name attribute pattern should be

                          portQName.http-conduit

                          So change

                          <http:conduit name="myService.http-conduit"

                          to

                          <http:conduit name="MathPort.http-conduit"

                           

                          in your blueprint configuration.

                           

                          Freeman

                          • 10. Re: how can i access a web service with basic authentication
                            pestar

                            freeman thank you for the quick answer!

                            now it works

                             

                            thanks to all who helped!

                             

                            peter

                             

                            Edited by: starpet on Oct 9, 2012 9:17 AM