Ok.   What a bizzare way to do authentication.   Using HTTP headers, but not 
using STANDARD https headers.   Strange.

In anycase, you would do something like:


Map<String, List<String>> headers = new HashMap...
header.put("username", Collections.singletonList("MyUserName"));
header.put("password", Collections.singletonList("MyPassWord"));
((BindingProvider)port).getRequestContext().put(
     Message.PROTOCOL_HEADERS, headers);

That should get the raw protocol headers set.

Dan



On Friday 23 April 2010 9:28:59 am Abderrazak BOUADMA wrote:
> Hello
> 
> I generated a service based on a wsdl I received from my customer, every
> thing works great and I ofcourse used the CXF tools to do that.
> My customer asked me to add authentication support , after a couple of
> questions I thought that the method to do that was a BASIC HTTP
> AUTHENTICATION, so I add this within my code :
> 
> 
> E3SmWasteServiceSoapBindingImplService service = null;
> service = new E3SmWasteServiceSoapBindingImplService(wsdlUrl);
>  *BindingProvider* port = (BindingProvider)
> service.getPort(E3SmWasteServiceSoapBindingImpl.class);
> port.getRequestContext().put(BindingProvider.USERNAME_PROPERTY,
> propertyHolder.getWsUsername());
>  port.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY,
> propertyHolder.getWsPassword());
> 
> 
> the problem is it's not working, it says that username and password are not
> defined, I also received this message from my customer   -just after my
> question-
> 
> *My Question*
> *should someone tell me what does it mean and what should I have to do to
> 'wrap' the service call to add HTTP header values ?:*
> 
> 
> 
> --- message received from customer
> 
> $CUSTOMER_NAME$ describes this authentication as "*HTTP Header*" as the
> username and password are added in two lines on the HTTP Header, as in the
> example .
> 
> POST
> http://localhost:7001/WSE3S/services/E3SmWasteServiceSoapBindingImplHTTP/1
> .1 Content-Type: text/xml;charset=UTF-8
> SOAPAction: ""
> username: Administrator
> password: PATATA
> User-Agent: Jakarta Commons-HttpClient/3.1
> Host: localhost:7001
> Content-Length: 3024
> <soapenv:Envelope xmlns:e3s="http://e3smwsdl_waste"; xmlns:soapenv="
> http://schemas.xmlsoap.org/soap/envelope/";>
> <soapenv:Header/>
> <soapenv:Body>
> <e3s:createWasteDCSfromDA>
> <e3s:wasteDCSFromDAParameter>
> <e3s:DCSAcceptanceData>
> <e3s:DCSAcceptance>
> <e3s:value>S</e3s:value>
> </e3s:DCSAcceptance>
> <e3s:DCSAcceptanceDate>2008-08-27T00:00:00</e3s:DCSAcceptanceDate>
> <!--1 or more repetitions:-->
> <e3s:DCSEffects>
> <e3s:effect>
> <e3s:effectCode>
> <e3s:value>99</e3s:value>
> </e3s:effectCode>
> <e3s:effectDescription>Otras</e3s:effectDescription>
> </e3s:effect>
> <e3s:effectObservations>Observaciones</e3s:effectObservations>
> </e3s:DCSEffects>
> <e3s:DCSRealQuantity>86</e3s:DCSRealQuantity>
> </e3s:DCSAcceptanceData>
> <e3s:DCSClearWeight>86</e3s:DCSClearWeight>
> <e3s:DCSDA>DA20460000744720100000002</e3s:DCSDA>
> <e3s:DCSGrossWeight>96</e3s:DCSGrossWeight>
> <e3s:DCSNT>NT20460000744720100000003</e3s:DCSNT>
> <e3s:DCSSendingOrder>1</e3s:DCSSendingOrder>
> <e3s:DCSTransportCharacteristics>CaracterÃsticas</e3s:DCSTransportCharacter
> istics> <!--1 or more repetitions:-->
> <e3s:DCSTransporterData>
> <!--1 or more repetitions:-->
> <e3s:DCSTransportData>
> <e3s:DCSTransportContainer>
> <e3s:containerCode>
> <e3s:value>02</e3s:value>
> </e3s:containerCode>
> <e3s:containerDescription>Contenedor</e3s:containerDescription>
> </e3s:DCSTransportContainer>
> <e3s:DCSTransportEndDate>2008-08-27T00:00:00</e3s:DCSTransportEndDate>
> <e3s:DCSTransportMatriculation>
> <e3s:containerMatriculation>8979HYT</e3s:containerMatriculation>
> <e3s:towMatriculation>1234DFR</e3s:towMatriculation>
> <e3s:vehicleMatriculation>4567GTR</e3s:vehicleMatriculation>
> </e3s:DCSTransportMatriculation>
> <e3s:DCSTransportStartDate>2008-08-27T00:00:00</e3s:DCSTransportStartDate>
> <e3s:DCSTransportWay>
> <e3s:transportWayCode>
> <e3s:value>03</e3s:value>
> </e3s:transportWayCode>
> <e3s:transportWayDescription>Terrestre</e3s:transportWayDescription>
> </e3s:DCSTransportWay>
> </e3s:DCSTransportData>
> <e3s:DCSTransporterCenterCode>0822221212</e3s:DCSTransporterCenterCode>
> </e3s:DCSTransporterData>
> <e3s:DCSVolume>67</e3s:DCSVolume>
> </e3s:wasteDCSFromDAParameter>
> </e3s:createWasteDCSfromDA>
> </soapenv:Body>
> </soapenv:Envelope>

-- 
Daniel Kulp
[email protected]
http://dankulp.com/blog

Reply via email to