Soap services are working fine after passing the parameters username and password under authentication tab in Soap UI but not working from java code.
Please find the Code as below:
ServicesLocator sl = new ServicesLocator();
ServicesSoapProxy proxy = new ServicesSoapProxy();
ServicesSoap serviceSoap = sl.getServicesSoap();
//Service s = new Service();
//Port port = s.getPort(); // if tried using service object s but s.getPort not coming in my code
Port port = (Port) sl.getPort(proxy.getEndpoint(),ServicesSoap.class);
BindingProvider prov = (BindingProvider)port;
prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "username");
prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "password");
//then calling SOAP Service
serviceSoap.callExternalSOAPSERVICE();
Error as shown below:
faultCode: {http://xml.apache.org/axis/}HTTP
faultSubcode:
faultString: (401)Unauthorized
faultActor:
faultNode:
faultDetail:
{}:return code: 401
Please suggest on this.