HTTP basic authentication through CXF interceptor not working

前端 未结 2 640
别跟我提以往
别跟我提以往 2021-02-08 12:23

I\'m having some trouble setting the HTTP Authorization header for a web service request using Apache CXF. I have my client setup through spring:



        
2条回答
  •  抹茶落季
    2021-02-08 13:28

    If you are looking to externalize the client and authentication best approach is to setup httpConduit in spring context..

     **in your spring context file...**
    
    
        
            
                file:${config.dir}/application.properties
            
        
        
     
      ...
      
        
            
                
            
        
        
            
                
            
        
      
      ...
    
    
    applicaiton.properties
    ---------------------
    webservices.http.auth.username=userName
    webservices.http.auth.password=Password
    webservice.soap.address=https://your.service.url/services/service
    

    a) by mentioning the SOAP Address in the name attribute. which your can find in your WSDL

    Ex: if in your WSDL..
        
        ...
        
             
    

    Then

    ...
    xmlns:http-conf="http://cxf.apache.org/transports/http/configuration"
    xmlns:sec="http://cxf.apache.org/configuration/security"
    ...
    
        
            ${webservices.http.auth.username}
            ${webservices.http.auth.password}
            Basic
        
    
    

    Or b) name attribute should be {targetNamespace}portName.http_conduit

    
        
            ${webservices.http.auth.username}
            ${webservices.http.auth.password}
            Basic
        
    
    

提交回复
热议问题