You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by kbhatt <kb...@rediffmail.com> on 2011/01/15 06:13:13 UTC

Web service return type List doesn't work

I have a requirement to return List of custom class(FeedMetaData) objects
from a web service method. When I invoke this method from client, I am
getting ClassCast Exception.

FeedMetaData is simple bean class with 3 fields of type String.

Below is the client code:

Bus bus = new CXFBusFactory().createBus();

JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(bus);

Client client =
dcf.createClient("http://64.68.163.33:8080/socialkast-web/skservice/skservice?wsdl");

Object[] results = client.invoke("getCommecialFeeds");

List<FeedMetaData> result = (List<FeedMetaData>)results[0];

I get ClassCastException at above line.

Then I looked into the issue https://issues.apache.org/jira/browse/CXF-2415
and changed my return type to List<String> but still getting the same
Exception.

java.lang.ClassCastException: tv.socialkast.ws.ArrayOfString cannot be cast
to java.util.List

Below is the client code to
 Bus bus = new CXFBusFactory().createBus();
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(bus); 
Client client =
dcf.createClient("http://64.68.163.33:8080/socialkast-web/skservice/skservice?wsdl");
Object[] results = client.invoke("getCommecialFeeds");
List<String> result = (List<String>)results[0];

Although when I invoke the web service method in jira CXF-2415, I could
successfully get the list of strings. It clearly indicates we have some
problem with our web service.

2 Questions:

1. What do I need to change in my web service configurations so I can return
List.
2. Is it possible to return list of objects of custom class ?

I appreciate any help on this.



Is it possible to return list of objects of custom class 
-- 
View this message in context: http://cxf.547215.n5.nabble.com/Web-service-return-type-List-T-doesn-t-work-tp3342349p3342349.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Web service return type List doesn't work

Posted by kbhatt <kb...@rediffmail.com>.
Thanks Pierre for your response.

I could manage to return the list of string response from web service
working. But still having problem to pass argument as list of custom
objects(in this case List<VideoMetaData>) to a web service method. When I
invoke the method , I get following error:


---------------------------------------------------------------------------------
INFO: Created classes: tv.socialkast.ws.GetCommecialFeeds,
tv.socialkast.ws.GetCommecialFeedsResponse, tv.socialkast.ws.ObjectFactory,
tv.socialkast.ws.SayHi, tv.socialkast.ws.SayHiResponse,
tv.socialkast.ws.UploadVideoMetaData,
tv.socialkast.ws.UploadVideoMetaDataResponse, tv.socialkast.ws.VideoMetaData
30 Jan, 2011 12:42:05 PM org.apache.cxf.phase.PhaseInterceptorChain
doDefaultLogging
WARNING: Interceptor for
{http://ws.socialkast.tv/}SocialKastServiceImplService#{http://ws.socialkast.tv/}uploadVideoMetaData
has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Marshalling Error: class
tv.socialkast.ws.model.VideoMetaData nor any of its super class is known to
this context.
	at
org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:247)
	at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
	at
org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:111)
	at
org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
	at
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:244)
	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.endpoint.ClientImpl.invoke(ClientImpl.java:285)
	at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:271)
	at
tv.socialkast.client.ws.WSClient.invokeUploadMetaDataService(WSClient.java:74)
	at
tv.socialkast.upload.client.gui.UploadDirectoryChooser$DoneActionListener.actionPerformed(UploadDirectoryChooser.java:424)
	at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
	at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
	at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
	at java.awt.Component.processMouseEvent(Unknown Source)
	at javax.swing.JComponent.processMouseEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
	at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Window.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: javax.xml.bind.MarshalException
 - with linked exception:
[javax.xml.bind.JAXBException: class tv.socialkast.ws.model.VideoMetaData
nor any of its super class is known to this context.]
	at
com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:318)
	at
com.sun.xml.bind.v2.runtime.MarshallerImpl.marshal(MarshallerImpl.java:244)
	at javax.xml.bind.helpers.AbstractMarshallerImpl.marshal(Unknown Source)
	at
org.apache.cxf.jaxb.JAXBEncoderDecoder.writeObject(JAXBEncoderDecoder.java:532)
	at
org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:222)
	... 36 more
-----------------------------------------------------------------------------------------------

Please let me know what am I missing here.

You can see the wsdl at

http://64.68.163.33:8080/socialkast-web/skservice/skservice?wsdl



-- 
View this message in context: http://cxf.547215.n5.nabble.com/Web-service-return-type-List-T-doesn-t-work-tp3342349p3363249.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: Web service return type List doesn't work

Posted by "phperret@gmail.com" <ph...@gmail.com>.
Hi,

>From your questions:

1. What do I need to change in my web service configurations so I can return
List. 

2. Is it possible to return list of objects of custom class ? 
    Yes it's possible it has been made for that (see jaxb specs)

For the first question  I cannot answer because I cant see the WSDL file on
the URL of your post, It throws an exception .



-----
--
Pierre
-- 
View this message in context: http://cxf.547215.n5.nabble.com/Web-service-return-type-List-T-doesn-t-work-tp3342349p3343358.html
Sent from the cxf-user mailing list archive at Nabble.com.