You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by dilipmd <di...@yahoo.com> on 2012/04/03 10:20:08 UTC

ClientPolicy issue in Websphere 7

I am trying to run a CXF client from embedded OSGi webapp in Websphere AS
7.0.0.21. The client using ClientPolicy class throws class cast exception
when gets invoked. I need ClientPolicy class to set HTTP headers like proxy
setting and also for HTTPS. I have seen in some forum where
jaxwsproxyfactorybean usage has been recommended but don't know if that can
be used for setting HTTP headers without ClientPolicy class.

below is the sample code:

...
Client client = ClientProxy.getClient(port);
HTTPConduit http = (HTTPConduit) client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy();
httpClientPolicy.setConnectionTimeout(config.getConnectionTimeout());
httpClientPolicy.setProxyServer(config.getProxyHost());
httpClientPolicy.setProxyServerPort(config.getProxyPort());
....

With default axis2 engine provided by WAS, the exception is:

java.lang.ClassCastException:
org.apache.axis2.jaxws.client.proxy.JAXWSProxyHandler incompatible with
org.apache.cxf.frontend.ClientProxy

With axis2 engine disabling the exception is :

java.lang.ClassCastException: com.sun.xml.internal.ws.client.sei.SEIStub
incompatible with org.apache.cxf.frontend.ClientProxy

I'm using below 2 CXF dependencies in pom.xml

<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.1.2</version>

<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.1.2</version>

The same code works fine in Tomcat, JBoss and Weblogic app servers. Only
problem appears in Websphere.

--
View this message in context: http://cxf.547215.n5.nabble.com/ClientPolicy-issue-in-Websphere-7-tp5614510p5614510.html
Sent from the cxf-dev mailing list archive at Nabble.com.

Re: ClientProxy issue in Websphere 7

Posted by dilipmd <di...@yahoo.com>.
This issue got resolved after using JaxWsProxyFactoryBean component.

Earlier, I was using generated class (from WSDL2Java tool) for generating
proxy and it was failing in  Websphere AS. 

Now with this, for creating JAX-WS proxies, slight modification as given
below was done:
 
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setAddress("http://myhost:myport/MyService/MyService?wsdl");
factory.setServiceClass(MyWebService.class);
EngineWebService port = (MyWebService) factory.create();

//and then call ClientProxy as usual but with the object created using
JaxWsProxyFactoryBean
Client client = ClientProxy.getClient(port); 
...

CXF is cool!

--
View this message in context: http://cxf.547215.n5.nabble.com/ClientProxy-issue-in-Websphere-7-tp5614510p5626900.html
Sent from the cxf-dev mailing list archive at Nabble.com.