You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Umut DOĞAN <na...@gmail.com> on 2008/04/02 10:19:25 UTC

A Solution without Modifying the STUB file?

I have created a webservice with Axis2 and in this service i used to return
my own KeyframeData class. This class has two fields, and their getter,
setter methods:

*private* String timeCode;
*private* String imageRef;

When I used to return KeyframeData it gives Unexpected Subelement timeCode
error everytime.

After modifying adb generated stub file, i solved the problem. But the
problem was solved in FFmpegServiceStub.java by this way.

I added these lines into the
*public*com.cyangate.ffmpeg.client.FFmpegServiceStub.GetVideoKeyframesResponse
getVideoKeyframes(
com.cyangate.ffmpeg.client.FFmpegServiceStub.GetVideoKeyframes
getVideoKeyframes)
*throws* java.rmi.RemoteException method before the cleanup call. (kData is
a KeyframeData object)

String imageRef = kData.getImageRef();
*if*(imageRef == *null*)
*continue*;
//remove the "cid:" prefix
imageRef = imageRef.substring(4);
//Accesing the attachment from the response message context using the ID
DataHandler dataHandler = _returnMessageContext.getAttachment(imageRef);
//just set the data handler so that we can get this from our own class
kData.setDataHandler(dataHandler);

And again in stub added these lines into *public* *static* *class*KeyframeData
*implements* org.apache.axis2.databinding.ADBBean section

*private* DataHandler dataHandler = *null*;
*public* DataHandler getDataHandler()
{
*return* *this*.dataHandler;
}
*public* *void* setDataHandler(DataHandler dataHandler)
{
*this*.dataHandler = dataHandler;
}

Then i used these lines in Client code by this way:

....
ByteArrayOutputStream buffOS= *new* ByteArrayOutputStream();
*if*(keyframe.getDataHandler() != *null*)
{
keyframe.getDataHandler().writeTo(buffOS);
videoKeyframe.setThumbnail(buffOS.toByteArray());
*_logger*.debug("Image Reference= " + i++ + keyframe.getImageRef());
videoKeyframelist.add(videoKeyframe);
}
....

Is there a possible way to do this, without touching the STUB? Because i
need to create the stub everytime i need to change service and these manual
modifications will be lost.

*PS: I use ADB data binding and axis2 1.3.*

Thanks a lot.
Have a nice day.