You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Valerio Schiavoni <va...@gmail.com> on 2009/02/14 00:53:47 UTC
ClassCastException setting SOAP headers (ClientProxyFactoryBean, cxf
2.1.4)
Hello,
i'm trying to attach contextual informations in the request/responses sent
by a client generated using the ClientProxyFactoryBean.
given this code:
@Test
public void testSetSoapHeaders() {
final ClientProxyFactoryBean clientProxyfactoryBean = new
ClientProxyFactoryBean();
clientProxyfactoryBean.setServiceClass(Service.class);
clientProxyfactoryBean.setAddress("http://localhost/Service?wsdl");
final Object cl = clientProxyfactoryBean.create();
ClientProxy cp = (ClientProxy) Proxy.getInvocationHandler(cl);
final ClientProxy client = (ClientProxy)
Proxy.getInvocationHandler(cl);
final Map<String, Object> requestContext =
client.getRequestContext();
List<Header> headers = new ArrayList<Header>();
Header txid = new Header(new QName("java.lang.String"), "1"); //
<--- if I use 1, the CCE is on java.lang.Integer
headers.add(txid);
requestContext.put(Header.HEADER_LIST, headers);
((Service) cl).print();
}
where service is simply:
interface Service {
void print();
}
i get this stacktrace:
java.lang.ClassCastException: java.lang.String
at
org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.writeSoapEnvelopeStart(SoapOutInterceptor.java:150)
at
org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:80)
at
org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor.handleMessage(SoapOutInterceptor.java:61)
at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:226)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:469)
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.frontend.ClientProxy.invoke(ClientProxy.java:68)
at $Proxy28.print(Unknown Source)
at
org.objectweb.fractal.bf.connectors.ws.ClientProxyTest.testSetSoapHeaders(ClientProxyTest.java:50)
I'm surely doing something wrong here..
Any help is very appreciated.
Valerio
--
http://www.linkedin.com/in/vschiavoni
http://jroller.com/vschiavoni