While I completely agree with Glen that redirecting from http to https is probably not a good idea, this is a "restriction" in CXF. If the conduit is created with "http", it won't work for https and vice versa. Two weeks ago, I fixed some parts of it to allow some configuration to change, but I missed the redirects. I just committed a fix to trunk to allow the redirect cases as well.
Dan On Tuesday 13 January 2009 10:42:00 am mzha wrote: > I configured in web.xml of my web-app to redirect http request to https. It > works well with the browser. But it does not work with my client. > If my client connects the service with https://... , it works fine, but > fails if http:// is in use. > > Best regards, > > Ming > > =============================================== > I defined the service endpoint like this > =============================================== > <jaxws:endpoint id="sessionService" > implementor="de.destatis.idb.web.ws.service.cxf.SessionWebServiceImpl" > address="/SessionService" > serviceName="SessionService"/> > =============================================== > I set the autoredirect programatically like this > =============================================== > Client client = this.clientProxyFactory.getClientFactoryBean().getClient(); > HTTPConduit conduit = (HTTPConduit) client.getConduit(); > HTTPClientPolicy clientPolicy = new HTTPClientPolicy(); > clientPolicy.setReceiveTimeout(2 * 60 * 1000); > clientPolicy.setAutoRedirect(true); > conduit.setClient(clientPolicy); > =============================================== > This is the log: > =============================================== > 13.01.2009 16:04:26 org.apache.cxf.transport.http.HTTPConduit prepare > INFO: AutoRedirect is turned on. > 13.01.2009 16:04:26 org.apache.cxf.phase.PhaseInterceptorChain doIntercept > INFO: Interceptor has thrown exception, unwinding now > org.apache.cxf.interceptor.Fault: Could not send Message. > at > org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInte >rceptor.handleMessage(MessageSenderInterceptor.java:64) at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai >n.java:220) at > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:466) at > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:299) at > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:251) at > org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) at > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124) at > $Proxy49.login(Unknown Source) > at > de.destatis.idb.web.ws.client.cxf.CXFWebServiceClientProxy$SessionWebServic >eClientImpl.login(CXFWebServiceClientProxy.java:179) at > de.destatis.idb.test.TestIDBSessionServiceClient.main(TestIDBSessionService >Client.java:35) Caused by: java.io.IOException: Illegal Protocol https for > HTTP > URLConnection Factory. > at > org.apache.cxf.transport.http.HttpURLConnectionFactoryImpl.createConnection >(HttpURLConnectionFactoryImpl.java:44) at > org.apache.cxf.transport.http.HTTPConduit.retransmit(HTTPConduit.java:1582) > at > org.apache.cxf.transport.http.HTTPConduit.redirectRetransmit(HTTPConduit.ja >va:1446) at > org.apache.cxf.transport.http.HTTPConduit.processRetransmit(HTTPConduit.jav >a:1367) at > org.apache.cxf.transport.http.HTTPConduit.access$300(HTTPConduit.java:135) > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRetrans >mits(HTTPConduit.java:1910) at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRespons >e(HTTPConduit.java:1937) at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCon >duit.java:1867) at > org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66) at > org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:595) at > org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInte >rceptor.handleMessage(MessageSenderInterceptor.java:62) ... 9 more > Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: Could not > send Message. > at > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:145) > at $Proxy49.login(Unknown Source) > at > de.destatis.idb.web.ws.client.cxf.CXFWebServiceClientProxy$SessionWebServic >eClientImpl.login(CXFWebServiceClientProxy.java:179) at > de.destatis.idb.test.TestIDBSessionServiceClient.main(TestIDBSessionService >Client.java:35) Caused by: org.apache.cxf.interceptor.Fault: Could not send > Message. at > org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInte >rceptor.handleMessage(MessageSenderInterceptor.java:64) at > org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChai >n.java:220) at > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:466) at > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:299) at > org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:251) at > org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73) at > org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124) ... > 3 more > Caused by: java.io.IOException: Illegal Protocol https for HTTP > URLConnection Factory. > at > org.apache.cxf.transport.http.HttpURLConnectionFactoryImpl.createConnection >(HttpURLConnectionFactoryImpl.java:44) at > org.apache.cxf.transport.http.HTTPConduit.retransmit(HTTPConduit.java:1582) > at > org.apache.cxf.transport.http.HTTPConduit.redirectRetransmit(HTTPConduit.ja >va:1446) at > org.apache.cxf.transport.http.HTTPConduit.processRetransmit(HTTPConduit.jav >a:1367) at > org.apache.cxf.transport.http.HTTPConduit.access$300(HTTPConduit.java:135) > at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRetrans >mits(HTTPConduit.java:1910) at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleRespons >e(HTTPConduit.java:1937) at > org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPCon >duit.java:1867) at > org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:66) at > org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:595) at > org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInte >rceptor.handleMessage(MessageSenderInterceptor.java:62) ... 9 more -- Daniel Kulp [email protected] http://dankulp.com/blog
