Reputation: 329
I'm implementing a Client Web Service and I need to convert code from Apache Axis2 with Apache CXF. Below is the code in Apache Axis2 which needs to be converted to CXF way of authentication:
_service = "http://mysite.custhelp.com/cgi-bin/myinterface.cfg/services/soap";
org.apache.axis2.client.ServiceClient serviceClient = ((org.apache.axis2.client.Stub)_service)._getServiceClient();
serviceClient.addHeader(createSecurityHeader("Username", "Password"));
Where createSecurityHeader will create be responsible for authenticating and providing a response in form of securityHeader.
Any help will be appreciated. Thanks, Jineet
Upvotes: 1
Views: 1029
Reputation: 109
I know it's probably too late to be able to help you, Jineet, but answering this question for the benefit of others who might have struggled like you and me trying to migrate from Axis to CXF.
You need to do both the steps described as the top 2 solutions of this stackoverflow question: Java Web Service client basic authentication
As per my understanding and experience, the first approach (BindingProvider) is required for authentication at SOAP protocol level to work. The second one (Authenticator) is required for authorization to access the SOAP service endpoint URL (HTTP/s level).
After making both these changes, my migration was successful.
Upvotes: 1