Hi,

My comment inline
On 2010-12-16, at 上午2:24, Juan Pablo Pizarro wrote:

Hello All, I'm trying to call a web service with Spring+CXF. The result is a exception java.lang.ClassCastException: org.apache.cxf.message.XMLMessage cannot be cast to org.apache.cxf.binding.soap.SoapMessage. My configuration
is:

Seems this exception is caused by you mismatch HTTP binding and Soap binding message. You use SAAJOutInterceptopr and WSS4JOUTInterceptor, which both should work with soap message, but somehow you provide HTTP binding message.


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans";
   xmlns:jaxws="http://cxf.apache.org/jaxws"; xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.xsd
   http://cxf.apache.org/jaxws
   http://cxf.apache.org/schemas/jaxws.xsd";>

   <import resource="classpath:META-INF/cxf/cxf.xml" />
   <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" />
<import resource="classpath:META-INF/cxf/cxf-extension-http- binding.xml"
/>
   <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />

<bean id="wsclient" class="org.tempuri.IStock" factory- bean="wsFactory"
       factory-method="create" />

<bean id="wsFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
       <property name="serviceClass" value="org.tempuri.IStock" />
       <property name="address"
value="http://wss.aduanas.gub.uy/LuciaWsSecurity/ Stock.svc" />
       <property name="outInterceptors">
           <list>
               <bean
class="org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor" />
               <ref bean="wss4jOutInterceptor" />
           </list>
       </property>
<property name="bindingId" value="http://apache.org/cxf/binding/http "
/>

You should change bindingId to
value="http://schemas.xmlsoap.org/soap/";
http://apache.org/cxf/binding/http is for HTTP binding, and HTTP binding message can't work with SAAJOutInterceptopr and WSS4JOUTInterceptor, those interceptors both expect SOAP message.

Freeman

       <property name="transportId" value="
http://schemas.xmlsoap.org/wsdl/soap/http"; />
   </bean>

   <bean id="wss4jOutInterceptor"
class="org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor">
       <constructor-arg>
           <map>
               <entry key="action" value="Signature Timestamp" />
               <entry key="signaturePropFile"
value="Client_Sign.properties" />
               <entry key="user"
value="le-60dca1be-6392-48b3-bbc2-0dfb1ab41d25" />
               <entry key="passwordCallbackRef">
                   <ref bean="signaturePwdCallback" />
               </entry>
           </map>
       </constructor-arg>
   </bean>

<bean id="signaturePwdCallback" class="org.jpp.ws.client.ClientCallback"
/>
</beans>


Somebody knows the reason? There are some example/tutorial to avoid the
error?


Thanks!!




WARNING: Interceptor for {
http://tempuri.org/}IStockService#{http://tempuri.org/}MensajeStock has
thrown exception, unwinding now
java.lang.ClassCastException: org.apache.cxf.message.XMLMessage cannot be
cast to org.apache.cxf.binding.soap.SoapMessage
   at
org .apache .cxf .binding .soap.saaj.SAAJOutInterceptor.handleMessage(SAAJOutInterceptor.java: 70)
   at
org .apache .cxf .phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java: 247)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:516)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
   at
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java: 124)
   at $Proxy36.mensajeStock(Unknown Source)
   at org.jpp.ws.client.Client.main(Client.java:65)
Dec 15, 2010 4:19:51 PM org.apache.cxf.phase.PhaseInterceptorChain unwind
WARNING: Exception in handleFault on interceptor
org.apache.cxf.binding.soap.saaj.saajoutintercep...@57f7cdc7
java.lang.ClassCastException: org.apache.cxf.message.XMLMessage cannot be
cast to org.apache.cxf.binding.soap.SoapMessage
   at
org .apache .cxf .binding .soap.saaj.SAAJOutInterceptor.handleFault(SAAJOutInterceptor.java:70)
   at
org .apache .cxf.phase.PhaseInterceptorChain.unwind(PhaseInterceptorChain.java: 411)
   at
org .apache .cxf .phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java: 294)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:516)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
   at
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java: 124)
   at $Proxy36.mensajeStock(Unknown Source)
   at org.jpp.ws.client.Client.main(Client.java:65)
Exception in thread "main" javax.xml.ws.http.HTTPException
   at
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java: 138)
   at $Proxy36.mensajeStock(Unknown Source)
   at org.jpp.ws.client.Client.main(Client.java:65)
Caused by: java.lang.ClassCastException: org.apache.cxf.message.XMLMessage
cannot be cast to org.apache.cxf.binding.soap.SoapMessage
   at
org .apache .cxf .binding .soap.saaj.SAAJOutInterceptor.handleFault(SAAJOutInterceptor.java:70)
   at
org .apache .cxf.phase.PhaseInterceptorChain.unwind(PhaseInterceptorChain.java: 411)
   at
org .apache .cxf .phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java: 294)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:516)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:313)
   at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:265)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
   at
org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java: 124)
   ... 2 more


--
Freeman Fang

------------------------

FuseSource: http://fusesource.com
blog: http://freemanfang.blogspot.com
twitter: http://twitter.com/freemanfang
Apache Servicemix:http://servicemix.apache.org
Apache Cxf: http://cxf.apache.org
Apache Karaf: http://karaf.apache.org
Apache Felix: http://felix.apache.org

Reply via email to