If you are getting a SOAP Fault back instead of a 401, that means the basic authentication has worked. It’s now trying to process the message on the server side and failing and thus returning a fault. You may need to check the logs on the server side to see what it thinks is wrong.
Dan On Apr 15, 2014, at 5:37 PM, akaine <[email protected]> wrote: > Hello, > > I have a dynamic client generated with DynamicClientFactory for a web > service that required a Basic authorization: > > DynamicClientFactory dcf = DynamicClientFactory.newInstance(); > Client client = dcf.createClient(wsdlLocation); > client.getEndpoint().getEndpointInfo().setAddress(uri.toString()); > > HTTPConduit http = (HTTPConduit)sr.getClient().getConduit(); > AuthorizationPolicy authPolicy = new AuthorizationPolicy(); > authPolicy.setAuthorizationType("Basic"); > authPolicy.setUserName(username); > authPolicy.setPassword(password); > http.setAuthorization(authPolicy); > > Object[] response = client.invoke(operationQName, someArgs); > > > On invoke I get an error: > > SEVERE: Server Error > org.apache.cxf.binding.soap.SoapFault: Server Error > at > org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.unmarshalFault(Soap11FaultInInterceptor.java:84) > at > org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:51) > at > org.apache.cxf.binding.soap.interceptor.Soap11FaultInInterceptor.handleMessage(Soap11FaultInInterceptor.java:40) > at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) > at > org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:113) > at > org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:69) > at > org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor.handleMessage(CheckFaultInterceptor.java:34) > at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) > at org.apache.cxf.endpoint.ClientImpl.onMessage(ClientImpl.java:781) > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1630) > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1520) > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1326) > at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56) > at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:635) > at > org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62) > at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307) > at org.apache.cxf.endpoint.ClientImpl.doInvoke(ClientImpl.java:502) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:411) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:314) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:267) > at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:287) > at serviceinvoker.ServiceReader.invokeOperation(ServiceReader.java:164) > at exec.Test_XI.main(Test_XI.java:65) > > Before I had the block altering HTTPConduit I was getting 401 error which > was expected, but according to other cases I found in cxf mailing lists this > block should have solved my problems. One thing I should mention though: The > default endpoint (defined in wsdl) uri is different from the one I'm > setting, though if I set everything as I have in my code in SoapUI for > example it works as it should. > > Any ideas why is this happening? This is the first time I'm trying to > connect to a service using Basic authorization so maybe I'm missing > something... > > > > > > -- > View this message in context: > http://cxf.547215.n5.nabble.com/Basic-authorization-in-dynamic-client-tp5742882.html > Sent from the cxf-user mailing list archive at Nabble.com. -- Daniel Kulp [email protected] - http://dankulp.com/blog Talend Community Coder - http://coders.talend.com
