CONFIDENTIAL & RESTRICTED Hello there.
Yesterday I was about to ask how, but then all of a sudden I found a solution that works for me. I will describe it for others who have similar problems (and also for the future me). So I generated a client through Axis2 1.7.9 and I use it to access a webservice on https://endpoint. To better report which client is being used and get a slightly different behavior from the loadbalancer I need to set User-Agent and some other header for all HTTP requests. Neither the Axis2 documentation nor Google could help me with an example working for recent versions of Axis2. I was inspired by http://blog.facilelogin.com/2011/02/adding-custom-http-headers-via-axis2.html although that solution did not work for me straight away. So here is what worked: MyWebserviceServiceStub stub = new MyWebserviceServiceStub(targetEndPoint); Options options = stub._getServiceClient().getOptions(); // this is for preemptive authentication HttpTransportPropertiesImpl.Authenticator auth = new HttpTransportPropertiesImpl.Authenticator(); uth.setUsername("user"); auth.setPassword("password"); options.setProperty(HTTPConstants.AUTHENTICATE, auth); auth.setPreemptiveAuthentication(true); auth.setAllowedRetry(false); // this is for the HTTP headers actually // inspired by https://stackoverflow.com/questions/12071798/how-to-add-a-http-header-to-a-soaprequest-in-java List headers = new ArrayList(); headers.add(new org.apache.axis2.context.NamedValue("myheader", "myvalue")); headers.add(new org.apache.axis2.context.NamedValue(HTTPConstants.HEADER_USER_AGENT, "blah")); options.setProperty(org.apache.axis2.transport.http.HTTPConstants.HTTP_HEADERS, headers); When now the methods of the stub get called you should see the authentication as well as the custom headers going out on the wire. I checked by setting the loglevel to debug for categories httpclient.wire.header and httpclient.wire.content. Best regards Hiran IMPORTANT - CONFIDENTIALITY NOTICE - This e-mail is intended only for the use of the individual or entity shown above as addressees . It may contain information which is privileged, confidential or otherwise protected from disclosure under applicable laws . If taIMPORTANT - CONFIDENTIALITY NOTICE - This e-mail is intended only for the use of the individual or entity shown above as addressees . It may contain information which is privileged, confidential or otherwise protected from disclosure under applicable laws . If the reader of this transmission is not the intended recipient, you are hereby notified that any dissemination, printing, distribution, copying, disclosure or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this transmission in error, please immediately notify us by reply e-mail or using the address below and delete the message and any attachments from your system. Amadeus Data Processing GmbH Geschaftsfuhrer: Sven Fuhrmeister, Sitz der Gesellschaft: Erding, HR Munchen 212770, Berghamer Strasse 6, 85435 Erding, Germanye reader of this transmission is not the intended recipient, you are hereby notified that any dissemination, printing, distribution, copying, disclosure or the taking of any action in reliance on the contents of this information is strictly prohibited. If you have received this transmission in error, please immediately notify us by reply e-mail or using the address below and delete the message and any attachments from your system . Amadeus Data Processing GmbH Gesch?ftsf?hrer: Dr. Wolfgang Krips Sitz der Gesellschaft: Erding HR M?nchen 48 199 Berghamer Strasse 6 85435 Erding Germany