You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by srikanthsettivari <sr...@gmail.com> on 2013/04/26 12:53:38 UTC

Type Converters in Camel

i have written converter class

@Converter
public class OutboundMessageConverter {
	@Converter
	public static com.gehcit.cp.ws.interop.OutboundMessage
convertToInterfaceEngineOutboundmessage(com.gehcit.cp.cem.outboundmessage.OutboundMessage
outboundMessage) {
		com.gehcit.cp.ws.interop.OutboundMessage interfaceengineoutboundmessage =
new com.gehcit.cp.ws.interop.OutboundMessage();
	
interfaceengineoutboundmessage.setSubscriptionName(outboundMessage.subscriptionName);
		interfaceengineoutboundmessage.setEvent(outboundMessage.getEvent());
		interfaceengineoutboundmessage.setMetaData(outboundMessage.getMetaData());
		interfaceengineoutboundmessage.setMessage(outboundMessage.getMessage());		
		return interfaceengineoutboundmessage;
	}

}

i have loaded this converter using 
src/main/java/META-INF/services/org/apache/camel/TypeConverter file.

this is my camel code:

com.gehcit.cp.cem.outboundmessage.OutboundMessage outboundMessage =
prepareOutboundMessage(payload, eventMessage);
exchange.getOut().setBody(outboundMessage);

In the destination endpoint  i am expecting
com.gehcit.cp.ws.interop.OutboundMessage object.

I am getting this error at the time of sending the data to destination end
point

org.apache.cxf.interceptor.Fault:
com.gehcit.cp.cem.outboundmessage.OutboundMessage cannot be cast to
com.gehcit.cp.ws.interop.OutboundMessage

Does camel do the automatically convertion what ever the destination
endpoint expects? 




--
View this message in context: http://camel.465427.n5.nabble.com/Type-Converters-in-Camel-tp5731607.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Type Converters in Camel

Posted by srikanthsettivari <sr...@gmail.com>.
Thanks



--
View this message in context: http://camel.465427.n5.nabble.com/Type-Converters-in-Camel-tp5731607p5731652.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Type Converters in Camel

Posted by Christian Müller <ch...@gmail.com>.
No. In your route you have to add

convertBodyTo(com.gehcit.cp.ws.interop.OutboundMessage.class)

This kicks in the type converter mechanism which will use the type
converter you developed.

Best,
Christian


On Fri, Apr 26, 2013 at 12:53 PM, srikanthsettivari <
srikanth.settivari@gmail.com> wrote:

> i have written converter class
>
> @Converter
> public class OutboundMessageConverter {
>         @Converter
>         public static com.gehcit.cp.ws.interop.OutboundMessage
>
> convertToInterfaceEngineOutboundmessage(com.gehcit.cp.cem.outboundmessage.OutboundMessage
> outboundMessage) {
>                 com.gehcit.cp.ws.interop.OutboundMessage
> interfaceengineoutboundmessage =
> new com.gehcit.cp.ws.interop.OutboundMessage();
>
>
> interfaceengineoutboundmessage.setSubscriptionName(outboundMessage.subscriptionName);
>
> interfaceengineoutboundmessage.setEvent(outboundMessage.getEvent());
>
> interfaceengineoutboundmessage.setMetaData(outboundMessage.getMetaData());
>
> interfaceengineoutboundmessage.setMessage(outboundMessage.getMessage());
>                 return interfaceengineoutboundmessage;
>         }
>
> }
>
> i have loaded this converter using
> src/main/java/META-INF/services/org/apache/camel/TypeConverter file.
>
> this is my camel code:
>
> com.gehcit.cp.cem.outboundmessage.OutboundMessage outboundMessage =
> prepareOutboundMessage(payload, eventMessage);
> exchange.getOut().setBody(outboundMessage);
>
> In the destination endpoint  i am expecting
> com.gehcit.cp.ws.interop.OutboundMessage object.
>
> I am getting this error at the time of sending the data to destination end
> point
>
> org.apache.cxf.interceptor.Fault:
> com.gehcit.cp.cem.outboundmessage.OutboundMessage cannot be cast to
> com.gehcit.cp.ws.interop.OutboundMessage
>
> Does camel do the automatically convertion what ever the destination
> endpoint expects?
>
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Type-Converters-in-Camel-tp5731607.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>