CamelContext context = new DefaultCamelContext();
                context.addRoutes(new RouteBuilder() {
                            public void configure() throws Exception {


----> Authenticator.setDefault(new MyAuthenticator());  


          from("direct:test")
                             
         .setHeader("operationNamespace",
constant("urn:microsoft-dynamics-schemas/page/calculator"))
         .setHeader("operationName", constant("compute"))
        .setHeader("SOAPAction",
constant("urn:microsoft-dynamics-schemas/page/calculator:compute"))
                       
  .
to("cxf://http://localhost:9080/WS/calculator?wsdlURL=classpath:test.wsdl&;
dataFormat=PAYLOAD")
                               
                             
                             }
                        });
                       
                        context.start();
                       
     String soap = "<soap:Envelope
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\";><soap:Body><compute
xmlns=\"urn:microsoft-dynamics-schemas/page/calculator\"><No>8545</No></compute></soap:Body></soap:Envelope>";
      
                                 
                        Endpoint endpoint =
context.getEndpoint("direct:test");
                        Exchange exchange = endpoint.createExchange();
                        ProducerTemplate template =
exchange.getContext().createProducerTemplate();
                       
                     // send to default endpoint
                     template.sendBody(endpoint,soap);


where 


MyAuthenticator  :

MyAuthenticator extends Authenticator {

    private final static String DOMAIN = "domain";
    private final static String SEPARATOR = "\\";
    private final static String USER = "user";
    private final static String PASSWORD = "pass";

    @Override
    public PasswordAuthentication getPasswordAuthentication() {
        return new PasswordAuthentication(DOMAIN + SEPARATOR
+ USER,PASSWORD.toCharArray());
    }
}



This is working

but i'm trying to do it the spring xml way.


I'have tried by adding this to camel xml file  :
--------------

<http:conduit
name="{urn:microsoft-dynamics-schemas/calculator}calculatorPort.http-conduit">
<http:client AllowChunking="false" MaxRetransmits="11"
Connection="Keep-Alive" ReceiveTimeout="60000" CacheControl="No-Cache"
/>

<http:authorization>
<sec:UserName>domain\\user</sec:UserName>
<sec:Password>pass</sec:Password>

</http:authorization>
</http:conduit>



-----------

but i have HTTP response '401: Unauthorized' when communicating with
http:...


Any idea ?

Kin regards



--
View this message in context: 
http://camel.465427.n5.nabble.com/Camel-CXF-authentication-tp5783664.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to