I have a strange situation going on while implementing Web service client. Request fired from SOAP UI is success and the HTTP request is as below:
POST http://xxxxxxxxxx/xx/xx/xxxxx/xxxxx HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "CreateUserSoap"
Content-Length: 1490
Host: xxxxxxxxxxxxxxxxxxx.net
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
Cookie: SMCHALLENGE=YES
Cookie2: $Version=1
Authorization: Basic ZHFhbgfdd6RFFQcdfgdm9vccQ=
<soap........./>
However when i fire the web service request from the application, for which i use apace cxf following HHTP Request is generated and i get a 403:Forbidden Error
ID: 1
Address: http://xxxxxxxxxx/xx/xx/xxxxx/xxxxx
Encoding: UTF-8
Http-Method: POST
Content-Type: text/xml
Headers: {Accept=[*/*], Authorization=[Basic ZHFhbgfdd6RFFQcdfgdm9vccQ=], SOAPAction= ["CreateUserSoap"]}
Payload: <soap....... />
I am not sure if the apache - cxf is generating the right http header as expected by the server. the soap envelope is same in both cases.
Below is the implementing java client code:
ClientWs clientWS= new ClientWs ();
ClientWSPortType portType = clientWS.getClientWSPort();
BindingProvider provider = (BindingProvider) portType;
Header dummyHeader = new Header(new QName("http://clientWS/wsdl", "ClientWS"), documentBuilder.parse(new ByteArrayInputStream(xmlString2.getBytes("UTF-8"))).getDocumentElement() ); --parsing the soap mesage
headers.add(dummyHeader);
provider.getRequestContext().put(Header.HEADER_LIST, headers);
provider.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, user_name);
provider.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, pass_word);