Using the BindingProvider things should definitely work for the actual SOAP calls. If you are getting a 401 there, something is certainly wrong someplace. I would use wireshark to make sure the Authentication token is properly there and such as well as check the server logs to see what it thinks is happening.
For the WSDL things, there are three options, none great: 1) Configure the username/password things into the cxf.xml config file for the conduit. 2) Try using a url like "http://username:passw...@localhost..." That sometimes works. 3) Register an java.net.Authenticator with the JVM. You would need to do this before any CXF HTTP related classes are loaded. Dan On Monday 18 October 2010 12:29:14 pm Jeffrey Rodgers wrote: > Hello: > > 2 questions - > > Using the generated classes from wsdl2java, I have been attempting to > insert basic authentication before moving to also activating SSL. I see > several mentions in the past about using the BindingProvider to set these > properties, however I am accessing the WSDL through the web service > (.asmx?WSDL). Thus the constructors throw exceptions before I can reach > the bindingproperty part of my code. Is there a different pattern to be > followed here when accessing external WSDLs through the generated classes? > > Secondly, if I instead simply use a local WSDL to move past that, I still > have a final issue in pointing the binding at the end point and getting a > 401 despite confirming the credentials: > > Srv ss = new Srv(wsdlURL, SERVICE_NAME); // wsdlURL > temporarily pointing at \temp\test.wsdl > SrvSoap port = ss.getSrvSoap(); > BindingProvider portBP = (BindingProvider)port; > > portBP.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, " > http://mywebservice.com:5600/srv.asmx"); > portBP.getRequestContext().put(portBP.USERNAME_PROPERTY, > "test_user"); > portBP.getRequestContext().put(portBP.PASSWORD_PROPERTY, > "test_pw"); > > I suspect I have some mis-use going on here. I have also read a wiki that > this may be an old pattern and one should simply use http-conduits either > through cxf.xml or dynamically ( > https://cwiki.apache.org/CXF20DOC/client-http-transport-including-ssl-suppo > rt.html). In this case I still suffer the same problem as in my first > question of course. > > Thanks in advance, > Jeff -- Daniel Kulp [email protected] http://dankulp.com/blog
